[LLVMbugs] [Bug 3577] New: clang does not detect some compile time constants.

bugzilla-daemon at cs.uiuc.edu bugzilla-daemon at cs.uiuc.edu
Fri Feb 13 13:34:53 PST 2009


           Summary: clang does not detect some compile time constants.
           Product: clang
           Version: unspecified
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Semantic Analyzer
        AssignedTo: unassignedclangbugs at nondot.org
        ReportedBy: bolzoni at cs.unipr.it
                CC: llvmbugs at cs.uiuc.edu, bagnara at cs.unipr.it

The following pieces of code are from the gcc test suite.
While gcc compiles without problems, clang does not detect that
the values assigned to the static variables are compile time known.

The last two pieces are really bizarre, but the other two use idioms
actually pretty common in low level C code.

struct{int c;}v;
static long i=((char*)&(v.c)-(char*)&v);

  char a, b, f[3];
} s;
long i = s.f-&s.b;

int foo (int a)
  static const short ar[] = { &&l1 - &&l1, &&l2 - &&l1 };
  void *p = &&l1 + ar[a];
  goto *p;
  return 1;
  return 2;

/*20001116-1.c */
int x[60];
char *y = ((char*)&(x[2*8 + 2]) - 8);
int z = (&"Foobar"[1] - &"Foobar"[0]);

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