This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/21166] New: g++ gives error on reference to packed structure elements
- From: "raj dot khem at gmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 22 Apr 2005 21:27:48 -0000
- Subject: [Bug c++/21166] New: g++ gives error on reference to packed structure elements
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
In the code below, the g++ is being overly picky about taking a reference to a
packed char. Chars can have any alignment so the error is incorrect. note
that the same code using pointers doesn't produce a similar error:
=====
struct s1 {
char c1;
} __attribute__((packed));
char&
f(struct s1 *s)
{
return s->c1;
}
char *
g(struct s1 *s)
{
return &s->c1;
}
--
Summary: g++ gives error on reference to packed structure
elements
Product: gcc
Version: 4.1.0
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: raj dot khem at gmail dot com
CC: gcc-bugs at gcc dot gnu dot org
GCC build triplet: i386-redhat-linux
GCC host triplet: i386-redhat-linux
GCC target triplet: i386-redhat-linux
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=21166