[Bug c++/36566] Cannot bind packed field
redi at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Wed Mar 18 01:56:00 GMT 2015
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=36566
--- Comment #8 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(In reply to Xiao Jia from comment #7)
> Adding "const" makes it compile. Is this the intended behavior or not?
Yes, of course. A const-reference causes a temporary to be created, you didn't
bind to the packed field:
Squeeze oj;
oj.s = 0;
const short& pit(oj.s);
oj.s = 1;
printf("%d %d", oj.s, pit);
This shows that oj.s and pit are not the same variable.
More information about the Gcc-bugs
mailing list