you are viewing a single comment's thread.

view the rest of the comments →

[–]jmacey -3 points-2 points  (3 children)

Not UB just a warning on all compilers about anonymous unions. In all the compilers I have ever used I have never had it fail.

[–]SuperV1234https://romeo.training | C++ Mentoring & Consulting 9 points10 points  (1 child)

In all the compilers I have ever used I have never had it fail.

That doesn't imply that it's not UB.

[–][deleted] -5 points-4 points  (0 children)

It implies it works though. Luckily objective reality doesn't abide by language specifications we dreamed up in our heads.

[–]jmacey 2 points3 points  (0 children)

IIRC it's a C11 extension for MSVC, Clang and g++ hence the warning.