[cfe-users] Undefined behaviour in a small code snippet

2018-03-19 Thread Łukasz Szczur via cfe-users
Hello, The program at the bottom prints 1 2 1 2 Does the code contain undefined behaviour in C++17 (note that the structs have common initial sequence )? Łukasz #include using namespace std; struct A { int first; int second; }; struct B { int first; int seco

Re: [cfe-users] Undefined behaviour in a small code snippet

2018-03-19 Thread Matthew Fernandez via cfe-users
I don’t have the reference on hand, but I’m pretty sure writing to one union member and reading the value back through another is undefined behaviour. I believe this is inherited from C99 or earlier. > On 19 Mar 2018, at 12:00, via cfe-users wrote: > > Send cfe-users mailing list submissions