This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/47273] References to unaligned packed structure members not allowed


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47273

--- Comment #8 from Richard Guenther <rguenth at gcc dot gnu.org> 2011-01-14 16:02:06 UTC ---
It works with

typedef int T __attribute__((aligned(1)));
struct s {
    T a;
    T& GetValr() { return a; }
} __attribute__((packed));


int main() {
    struct s s1;

    s1.GetValr() = 5;
}

so it's probably to guard you against crashes on targets that do
not support unaligned accesses (*(int&) is aligned but s1.b is not).
Note that the above will still not do what is necessary for such
targets.

The pointer case is probably supported for legacy reasons.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]