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++/15270] New: bogus error on offsetof(struct, element-of-member-array)


Th program below fails to compile with g++ 3.4. It compiles without a diagnostic
with gcc. I'm not aware of anything that makes the program ill-formed in C++
while valid in C. All other compilers I tried compile it fine.

$ cat t.c && g++ t.c || gcc --version
/*   1 */ #include <stddef.h>
/*   2 */ 
/*   3 */ struct S
/*   4 */ {
/*   5 */     int m [1][1];
/*   6 */ };
/*   7 */ 
/*   8 */ int main ()
/*   9 */ {
/*  10 */     return !offsetof (struct S, m [0]);
/*  11 */ }
/*  12 */ 
t.c: In function `int main()':
t.c:10: error: an array reference cannot appear in a constant-expression
gcc (GCC) 3.4.0
Copyright (C) 2004 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

-- 
           Summary: bogus error on offsetof(struct, element-of-member-array)
           Product: gcc
           Version: 3.4.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: sebor at roguewave dot com
                CC: gcc-bugs at gcc dot gnu dot org


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


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