Arguably true for code you write yourself. The problem comes from templates, which can generate a lot of code that really should be dead-code-eliminated. The back end has trouble knowing the difference.
Reminded me of one anti-pattern that I've seen in at least two projects in their legacy code: `if (this == NULL) return;`. Obviously, the compiler has the right to throw it all away, because `this` is not allowed to be null.
@ 33:00 when i compile that with clang 10, it emits an ud2 instruction, or 0F0B. "Raise invalid opcode exception". When run, this will trigger a segfault with "illegal hardware instruction (core dumped)"
25:00 if it would not be static then that means, there could be somewhere extern in another compilation unit and initialization before main and it could not do this.
49:00 Regarding the memory allocation thing: You know, you can just turn on strict accounting (by turning off overcommit). That has other problems, though.
Useful part: 16:17, 20:23-21:09, 29:51, 35:00-35:37, 43:34. 1. Your if statement about checking nullptr wil be considered by Compiler to check undefined behaviour. 2. Don't forget return statement at every branch. 3. Undefined Behaviour means assuming not happen, to speed up. In short: don't write smart (short) code then you will be fine.
Its pretty obvious “awesome” is meant literally, as in “inspiring an overwhelming feeling of reverence, admiration, or fear”
It's ridiculous how much code compiler can remove but you don't notice it in any way.
Arguably true for code you write yourself. The problem comes from templates, which can generate a lot of code that really should be dead-code-eliminated. The back end has trouble knowing the difference.
Reminded me of one anti-pattern that I've seen in at least two projects in their legacy code: `if (this == NULL) return;`.
Obviously, the compiler has the right to throw it all away, because `this` is not allowed to be null.
51:47 - was that Niko Matsakis(sounded like him) at CppCon 2017? :)
@ 33:00 when i compile that with clang 10, it emits an ud2 instruction, or 0F0B. "Raise invalid opcode exception". When run, this will trigger a segfault with "illegal hardware instruction (core dumped)"
25:00 if it would not be static then that means, there could be somewhere extern in another compilation unit and initialization before main and it could not do this.
49:00 Regarding the memory allocation thing: You know, you can just turn on strict accounting (by turning off overcommit). That has other problems, though.
Is "Behaviour" in the title of the video a typo or something else?
it is still correct. "Behaviour" is UK english and "Behavior" is US english
Useful part: 16:17, 20:23-21:09, 29:51, 35:00-35:37, 43:34.
1. Your if statement about checking nullptr wil be considered by Compiler to check undefined behaviour.
2. Don't forget return statement at every branch.
3. Undefined Behaviour means assuming not happen, to speed up.
In short: don't write smart (short) code then you will be fine.
24:34 OMG
W- what did you just say?