News for hackers. Stuff that matters.
Re:C++ by Example by kazinator on Thursday September 22, 2022 @01:58PM (#32942418)
> C++ without strict aliasing is not C++ anymore

That is completely false.

Firstly, a C++ implementation that doesn't optimize based on no aliasing assumptions can be entirely conforming: it can handle all correct, portable programs in the required way.

Secondly, the handling for programs which do type punning doesn't make it not C++ anymore; just a dialect. Programs in that dialect are C++, just not ISO C++.

Every implementation of a standardized language is a dialect of that language; the standard just explains what is the common dialect (theoretically) supported by all of them.

In fact it's common for C and C++ compilers to recognize their own dialect by default.

Re:C++ by Example by arcticbull on Thursday September 22, 2022 @04:05PM (#32943945)
> That is completely false.

I suppose but only because C++ is everything and nothing. C++ compilers are borderline self aware because the spec is 'write literally whatever you want'. Skynet was obviously a C++ compiler ;)

Re:C++ by Example by kazinator on Thursday September 22, 2022 @06:10PM (#32945280)
The meaning of punning memory is obvious if you understand the implementation-specific representations being used. E.g. if you understand what a 64 bit double looks like and what a 64 bit integer looks like, then it makes sense when you look at the memory of one through the type of the other. The C or C++ program to it has only two rationally defensible meanings: "undefined behavior" (ISO C or C++ interpretation, allowing certain optimizations, or run-time diagnosis of a type mismatch or whatever) or else "do the obvious thing and access the bits like the code says". What the code is asking for can certainly be be framed in terms of concepts in the standard. Just what the code is obviously requesting is not granted by any requirements in the standard. The idea that by asking for it, it's not a C++ program any more is silly.

There is no standardized programming language that doesn't have vendor specific extensions comprising a local dialect.