[Bug c++/50608] New: cannot apply 'offsetof' to a non constant address

dberger at oubliette dot org gcc-bugzilla@gcc.gnu.org
Mon Oct 3 23:41:00 GMT 2011


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

             Bug #: 50608
           Summary: cannot apply 'offsetof' to a non constant address
    Classification: Unclassified
           Product: gcc
           Version: 4.6.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: dberger@oubliette.org


$ cat repro.ii

struct A {
    int offset;
};

struct B: public A {
};

struct C {
    A a;
    B b;
};

/* error: cannot apply 'offsetof' to a non constant address */
int fails = __builtin_offsetof (C, b.offset);

int works = (int)(&(((C*)0)->b.offset));

$

looks like a dup of Bug 13648, which claims to be fixed.



More information about the Gcc-bugs mailing list