[LLVMbugs] [Bug 17818] New: variable-sized object check seems to be too restrictive

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Tue Nov 5 06:43:29 PST 2013


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

            Bug ID: 17818
           Summary: variable-sized object check seems to be too
                    restrictive
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++
          Assignee: unassignedclangbugs at nondot.org
          Reporter: luciupl at o2.pl
                CC: dgregor at apple.com, llvmbugs at cs.uiuc.edu
    Classification: Unclassified

The following code compiles successfully on g++ and msvc but clang reports
error: variable-sized object may not be initialized.
It seems both tables, table1 and table2, have a constant size determined by
asize static integer constant.

struct C {
  const static int asize = 3;
};

int main() {
  C c1;
  int table1[c1.asize] = { 0 }; // This compiles OK

  C *c2 = new C;
  int table2[c2->asize] = { 0 }; // This cause an error: variable-sized object
may not be initialized
}

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20131105/b3703afb/attachment.html>


More information about the llvm-bugs mailing list