[Bug c++/77388] Reference to a packed structure member
andre.simoesdiasvieira at arm dot com
gcc-bugzilla@gcc.gnu.org
Fri Aug 26 10:56:00 GMT 2016
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77388
--- Comment #3 from Andre Vieira <andre.simoesdiasvieira at arm dot com> ---
Thank you Richard!
I have a follow up question. Why is this only a problem when passing by
reference and not when passing a pointer?
So say:
#define PACKED __attribute__ ((packed))
#define TYPE_C short
typedef struct {
TYPE_C c;
} PACKED test_struct;
class A
{
const TYPE_C * c;
public:
A (const TYPE_C * _c) :
c(_c) {};
};
class B
{
public:
B();
A foo ();
private:
test_struct * s;
};
A B::foo ()
{
return A (&(s->c));
}
Wouldn't there still be an alignment mismatch between A::c and s->c?
More information about the Gcc-bugs
mailing list