[LLVMbugs] [Bug 8836] New: Microsoft's offsetof not recognized as constant expression

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Tue Dec 21 05:06:58 PST 2010


http://llvm.org/bugs/show_bug.cgi?id=8836

           Summary: Microsoft's offsetof not recognized as constant
                    expression
           Product: clang
           Version: trunk
          Platform: PC
        OS/Version: Windows NT
            Status: NEW
          Severity: normal
          Priority: P
         Component: Frontend
        AssignedTo: unassignedclangbugs at nondot.org
        ReportedBy: tetra2005 at gmail.com
                CC: llvmbugs at cs.uiuc.edu


The following code uses definition of offsetof from MSVS 9 2008 stddef.h:

// This is from stddef.h
#define offsetof(s,m) (unsigned)&reinterpret_cast<const volatile char&>((((s
*)0)->m))

struct B { char _; long long a; };

int a[ offsetof(B, a) == 8 ? 1 : 2 ];

This fails to parse with message:

u:\kernel\kernel2.cpp(7) :  error: variable length array declaration not
allowed at file scope
int a[ offsetof(B, a) == 8 ? 1 : 2 ];
    ^  ~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 error generated.

VC9 is able to compile it.

-- 
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.



More information about the llvm-bugs mailing list