Optimizing C++ Const Objects in LLVM
docs.google.com
docs.google.com
Unions are used for interpreting any kind of record stream. Reading serialized binary objects from a file? Use a union. Network packets? A union.
I don't know if this is the best example. Generally you see unions in C to cover "tagged unions", I.e. Those things that would be subsumed by algebraic data types in other languages.
(I have my reservations about whether ISO Core C++ with the lifetime profile really qualifies as C++ anymore due the massively backwards incompatible nature of the changes, but it'll be interesting nonetheless.)
Is the idea that they'll codify a bunch of static analysis that disallows problematic constructs & patterns? Could implementers then add something like Rust's ownership checks (assuming full source visibility)?
Microsoft has delivered a beta version of it with VS 2015 Update 1.
Clang guys are improving clang-tidy for similar errors.
Check Herb Sutter's talk at CppCon 2015.
Sutter comments on const_cast around 11m15s.
I'm excited to see this all play out though!
'inline' would be a better example of another "ignored" keyword.
As far as I know, there is no meaning in pointer-to-const other than it must not be used directly to modify the stored value (if it is you get a compile error). It is always valid from the perspective of language semantics to cast-away the const and modify the pointed-to object, as long as the object is not itself read-only. So, to my knowledge, they could not make any additional assumptions based on pointer-to-const, though they could use it as a hint to look for a possible optimization.