3 ms·
To me this talk was rather confusing. This statement cannot occur in a well formed standard C or C++ program, and I don’t think that the speaker did a good job
by ribit 3y ago
To me this talk was rather confusing. This statement cannot occur in a well formed standard C or C++ program, and I don’t think that the speaker did a good job conveying this. They also took way too much time to get to the actual point. If the intention was to discuss the particularities of memory mapping on some popular systems, they should have used bitcast from the start.
- jeffbee 3y ago> they should have used bitcast from the start. There are hundreds of instances of (char)0=0; in github, and there are none of the bit_cast variant, so if your goal is to inform people how to read code, starting with the one humans might actually encounter in the wild makes sense.
- sargstuff 3y agoMost assembler instructions are bit manipulations. just use gcc -S to cast the source code to bits.
- nayuki 3y ago> This statement cannot occur in a well formed standard C or C++ program Not true. It's illegal to execute that statement because of undefined behavior. But it's legal to have: if (false) { *(char*)0 = 0; } (And of course it's legal to #ifdef it out or comment it out, but that's too much cheating.)
- sargstuff 3y agoUmm... lot of undefined behavior things in official C spec.