[LLVMbugs] [Bug 3003] New: clang: does not treat expression involving struct pointer as a constant in array declaration

bugzilla-daemon at cs.uiuc.edu bugzilla-daemon at cs.uiuc.edu
Sat Nov 1 20:52:24 PDT 2008


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

           Summary: clang: does not treat expression involving struct
                    pointer as a constant in array declaration
           Product: clang
           Version: unspecified
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Semantic Analyzer
        AssignedTo: unassignedbugs at nondot.org
        ReportedBy: richard at godbee.net
                CC: llvmbugs at cs.uiuc.edu
            Blocks: 2778


This is a reduced version of another parser reject from DragonFly BSD's kernel
source (see bug 2778).

(If you think this is ugly, you should see the original code in all of its
expanded macro glory...)


struct str1 { char c; };

struct str2 {
  int intarray[ (int)&((struct str1 *)0)->c + 1];
};


% gcc-4.2 -W -Wall -pedantic -fsyntax-only -std=c99 array-length.c

% clang -fsyntax-only -std=c99 array-length.c
array-length.c:4:7: error: arrays with static storage duration must have
constant integer length
  int intarray[ (int)&((struct str1 *)0)->c + 1];
      ^~~~~~~~
1 diagnostic generated.


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