[LLVMbugs] [Bug 8209] New: typedef + dynamic array size + operator new = incorrect code

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Thu Sep 23 00:17:46 PDT 2010


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

           Summary: typedef + dynamic array size + operator new =
                    incorrect code
           Product: clang
           Version: trunk
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++
        AssignedTo: unassignedclangbugs at nondot.org
        ReportedBy: oneill+llvmbugs at cs.hmc.edu
                CC: llvmbugs at cs.uiuc.edu, dgregor at apple.com


Created an attachment (id=5516)
 --> (http://llvm.org/bugs/attachment.cgi?id=5516)
Sample code showing bug

Both g++ and clang++ allow you to write a typedef with dynamic size.  Both seem
to know what it means in principle, but only g++ currently generates correct
code.

If you run the attached simple test program (./dyntypedef 1 2 3) under g++, you
get

  Without typedef...
  sizeof(int[argc]) = 16
  operator new[](16)

  With typedef...
  sizeof(arr) = 16
  operator new[](16)


but if you run it with clang++, you get

  Without typedef...
  sizeof(int[argc]) = 16
  operator new[](16)

  With typedef...
  sizeof(arr) = 16
  operator new(0)

Results are indepenent of optimizaiton settings, etc.  Bug present in many
prior versions of clang++.

clang version 2.9 (trunk 114629)
Target: x86_64-unknown-linux-gnu
Thread model: posix

gcc version 4.4.3 (Ubuntu 4.4.3-4ubuntu5)

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