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

           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: [email protected]
        ReportedBy: [email protected]
                CC: [email protected], [email protected]


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.


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


/*930326-1.c*/
struct
{
  char a, b, f[3];
} s;
long i = s.f-&s.b;
/*end*/


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


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


-- 
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.
_______________________________________________
LLVMbugs mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/llvmbugs

Reply via email to