Live data from Hacker News

Retiring a favourite C++ joke

ignition-training.com

31–40 of 151 posts

Re: Retiring a favourite C++ joke

#33

Do modern cars even allow you to step on the accelerator and the brake at the same time?

I guess you technically can’t in an EV with regenerative braking. (But maybe they do have an actual brake pedal?)

Non-EV driver here; glad I did a search making the "obvious" reply. Surprisingly, "one pedal driving mode" is a thing. Its described as opt-in with a switch or setting, so I guess there's still a brake pedal. Which means some QA techs must have test plans with "switch off, step on brake pedal" and "switch on, step on brake pedal." Or maybe "switch on, step on brake pedal" is undefined behavior and the compiler can optimize it out.

Re: Retiring a favourite C++ joke

#34
Hey, it actually works!

    int main() {
        int tobias[24] = {0,0,33};
        delete(tobias+4);
    }
Compile and run on Ubuntu 20.04 (may work on other Linuxes), no errors, no warnings, runs perfectly fine.

Bonus fun: try printing out the address of `tobias` and `new int[6]` afterwards :)

Re: Retiring a favourite C++ joke

#35
post #17

Even the compilers are in on some jokes: $ gcc -xc - : In function ‘main’: :1:45: error: ‘long long long’ is too long for GCC

The old MPW compiler had some gems:

https://www.cs.cmu.edu/~jasonh/personal/humor/compile.html

> This label is the target of a goto from outside of the block containing this label AND this block has an automatic variable with an initializer AND your window wasn't wide enough to read this whole error message

Re: Retiring a favourite C++ joke

#36

Do modern cars even allow you to step on the accelerator and the brake at the same time?

I guess you technically can’t in an EV with regenerative braking. (But maybe they do have an actual brake pedal?)

My Kona Electric has brake and accelerator pedals. IIRC if you press both at the same time, the accelerator pedal is ignored.

Re: Retiring a favourite C++ joke

#37
post #29
post #22

Earlier quoted context omitted.

According to the TIOBE index, C++ is the fourth most popular programming language, and has been around for over 35 years, so easily a couple thousand people. The question is how many of them are on HN (probably dozens).

Either you did not get the joke, or I did not get your joke.

I mean, estimating that there are a couple thousand c++ developers is pretty funny.

Re: Retiring a favourite C++ joke

#38
I was surprised to see it not mentioned in the post -- the most obvious reason this joke should be retired is not the reference to a television show but rather the modern practice of never using new or delete at all in C++ code. Modern C++ avoids these pitfalls and I think it's been 10 years since I've written the words the new or delete.

Re: Retiring a favourite C++ joke

#40

#include using namespace std; class BadProgrammer { public: void yep() { delete this; } }; int main() { auto x = BadProgrammer{}; x.yep(); cout g++ -Wall -Wextra -Wpedantic main.cc # compiles just fine clang++ -Wall -Wextra -Wpedantic main.cc # also compiles just fine

[deleted]
Post reply on HN