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.

Reply via email to