[Bug c/90167] invalid example in GCC documentation wrt. effective type rules

2019-04-20 Thread segher at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90167 Segher Boessenkool changed: What|Removed |Added Status|UNCONFIRMED |RESOLVED CC|

[Bug c/90167] invalid example in GCC documentation wrt. effective type rules

2019-04-23 Thread lersek at redhat dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90167 --- Comment #2 from Laszlo Ersek (RH) --- (In reply to Segher Boessenkool from comment #1) > The code accesses d, of type double, as an int. That is not a > compatible type. Agreed; I didn't claim it was. > It does not matter how it got there,

[Bug c/90167] invalid example in GCC documentation wrt. effective type rules

2019-04-23 Thread segher at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90167 --- Comment #3 from Segher Boessenkool --- But you are not accessing as the union type. You do the access with the type of one of its members. And that is UB. The part of the standard you quote is about things like union a_union f(double *p)

[Bug c/90167] invalid example in GCC documentation wrt. effective type rules

2019-04-24 Thread lersek at redhat dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90167 --- Comment #4 from Laszlo Ersek (RH) --- So one way to define the behavior for the original example (from the gcc docs) would be: int f(void) { double d = 3.0; union a_union u = *(union a_union *)&d; return u.i; } Thanks.