[LLVMbugs] [Bug 3868] New: "initializer element is not a compile-time constant" for " &a + 4" but not "&a[4]"

bugzilla-daemon at cs.uiuc.edu bugzilla-daemon at cs.uiuc.edu
Mon Mar 23 17:32:59 PDT 2009


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

           Summary: "initializer element is not a compile-time constant" for
                    "&a + 4" but not "&a[4]"
           Product: clang
           Version: unspecified
          Platform: PC
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Semantic Analyzer
        AssignedTo: unassignedclangbugs at nondot.org
        ReportedBy: kremenek at apple.com
                CC: llvmbugs at cs.uiuc.edu


Clang allows '&a[4]'  to be treated as a compile-time constant but not '&a +
4':

$ cat test.c
struct foo {
    unsigned long x;
};

extern char a[];

struct foo b = {
    (unsigned long)&a + 4
};

struct foo c = {
    (unsigned long)&a[4]
};

$ clang test.c
test.c:7:16: error: initializer element is not a compile-time constant
struct foo b = {
               ^


I've seen this occur in real C code.


-- 
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