The following invalid code snippet triggers an ICE since GCC 4.0.0:

=====================================
struct A
{
  static int i;
};

int j = __builtin_offsetof(volatile A, i);
=====================================

bug.cc:6: internal compiler error: in fold_offsetof_1, at c-common.c:6316
Please submit a full bug report, [etc.]


In addition there are diagnostic issues with a similar testcase:

=====================================
struct A
{
  static void foo();
};

int i = __builtin_offsetof(volatile A, foo[0]);
=====================================

bug.cc:6: error: pointer to a function used in arithmetic
bug.cc:6: error: cannot apply 'offsetof' to member function '#'compound_expr'
not supported by dump_decl#<declaration error>'

Testing a patch.


-- 
           Summary: [4.1/4.2/4.3 regression] Trouble with __builtin_offsetof
                    and volatile
           Product: gcc
           Version: 4.3.0
            Status: UNCONFIRMED
          Keywords: ice-on-invalid-code, diagnostic, monitored
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: reichelt at gcc dot gnu dot org
        ReportedBy: reichelt at gcc dot gnu dot org


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

Reply via email to