for this kind of errors is why you always leave a comment on your code
Retiring a favourite C++ joke
141–150 of 151 posts
Re: Retiring a favourite C++ joke
#142Earlier quoted context omitted.
Nope, it is called experience with large code and teams.
We are talking about one very specific issue, the point of this thread is a joke about new and delete. And your response after evidence services against your position is, “what about all these other things?” Definition of whataboutism.
Also chromium code base is one example from many others, and it is so modern C++ that Google has finally decided to adopt Rust as only viable alternative to improving it.
Big G has plenty of samples that aren't so modern, specially on Android. Which by the way is also moving away from C++ instead of "modernising" it.
Re: Retiring a favourite C++ joke
#143Earlier quoted context omitted.
Since that counter can only have two values, it's storage is optimized and merged with the underlying raw pointer itself (not unlike Rust's null pointer optimization for enums): non-null value of the underlying pointer also serve to represent the counter's value of 1, and the null value serves to represent the counter's value of 0. The check to not under-decrement, for example, manifests as the null check before call…
Sigh, I saw this coming. By this definition, every C++ object with a (non-trivial) destructor would be "reference counted". Sorry, but I am not interested in playing word games.
Re: Retiring a favourite C++ joke
#144Earlier quoted context omitted.
FWIW the behavior of delete on a pointer that isn’t either null or returned from new is undefined. So a conforming C++ compiler doesn’t have to diagnose this mistake, and similarly the compiled program doesn’t have to do anything meaningful either. For example, just ignoring the delete and printing the message is as valid a result as the more useful crash at the site of the bad operation.
That this situation is "working as intended" and there are programmers who do not see a problem with that is... well it makes me despair.
Re: Retiring a favourite C++ joke
#145Earlier quoted context omitted.
Since that counter can only have two values, it's storage is optimized and merged with the underlying raw pointer itself (not unlike Rust's null pointer optimization for enums): non-null value of the underlying pointer also serve to represent the counter's value of 1, and the null value serves to represent the counter's value of 0. The check to not under-decrement, for example, manifests as the null check before call…
Sigh, I saw this coming. By this definition, every C++ object with a (non-trivial) destructor would be "reference counted". Sorry, but I am not interested in playing word games.
Edit: actually, nevermind. You are (almost) right: all objects with automatic storage duration and with non-trivial destructors are, very pedantically speaking, reference counted; but objects with dynamic storage duration are not. So RAII works by leveraging the built-in very primitive and restricted (binary) form of reference counting and builds on top of it to be able to reference-count objects with dynamic storage duration as well.
Re: Retiring a favourite C++ joke
#146Earlier quoted context omitted.
Sigh, I saw this coming. By this definition, every C++ object with a (non-trivial) destructor would be "reference counted". Sorry, but I am not interested in playing word games.
Nope. Only those with "if (this->inner_resource) { /* delete inner resource */ }" inside the destructor could count, others wouldn't. Edit: actually, nevermind. You are (almost) right: all objects with automatic storage duration and with non-trivial destructors are , very pedantically speaking, reference counted; but objects with dynamic storage duration are not. So RAII works by leveraging the built-in very primitiv…
Re: Retiring a favourite C++ joke
#147Earlier quoted context omitted.
We are talking about one very specific issue, the point of this thread is a joke about new and delete. And your response after evidence services against your position is, “what about all these other things?” Definition of whataboutism.
Nope, the whole issue is about modern C++ in practice versus slideware at conferences. Also chromium code base is one example from many others, and it is so modern C++ that Google has finally decided to adopt Rust as only viable alternative to improving it. Big G has plenty of samples that aren't so modern, specially on Android. Which by the way is also moving away from C++ instead of "modernising" it.
Re: Retiring a favourite C++ joke
#148Earlier quoted context omitted.
Nope, the whole issue is about modern C++ in practice versus slideware at conferences. Also chromium code base is one example from many others, and it is so modern C++ that Google has finally decided to adopt Rust as only viable alternative to improving it. Big G has plenty of samples that aren't so modern, specially on Android. Which by the way is also moving away from C++ instead of "modernising" it.
This is just a petty digression. I won't participate further. Have a nice day.
Re: Retiring a favourite C++ joke
#149Earlier quoted context omitted.
This is just a petty digression. I won't participate further. Have a nice day.
Finally! One "modern C++" advocate less.
Ironic bio for someone opposed to modern C++ advocates.
Re: Retiring a favourite C++ joke
#150Earlier quoted context omitted.
yes, I would have thought the "better" version would be int tobias[24]; delete tobias;
I'll be honest, I didn't get it at first. I thought initially that it was too complex for the teaching example. And then it clicked. You're rather smart aren't you! I guess 24, or 36, or 48 would have worked!