[LLVMbugs] [Bug 10060] New: Overloaded operator new[] gets a wrong argument value
bugzilla-daemon at llvm.org
bugzilla-daemon at llvm.org
Wed Jun 1 07:01:23 PDT 2011
http://llvm.org/bugs/show_bug.cgi?id=10060
Summary: Overloaded operator new[] gets a wrong argument value
Product: clang
Version: 2.9
Platform: Macintosh
OS/Version: MacOS X
Status: NEW
Severity: normal
Priority: P
Component: C++
AssignedTo: unassignedclangbugs at nondot.org
ReportedBy: mikhail.kalugin at gmail.com
CC: llvmbugs at cs.uiuc.edu, dgregor at apple.com
== Steps to reproduce (you can find the complete source code in the
attachment.):
1. Overload operator new[]:
inline void * operator new[] (std::size_t size) throw(std::bad_alloc) {
printf("new[] was called with size = %lu\n", size);
return NULL;
}
2. Allocate an array, where array size is a variable:
std::size_t cnt = 7;
int * a = new int[cnt];
== Expected behavior:
"new[] was called with size = 28" is printed
== Actual behavior:
"new[] was called with size = 4294967295" is printed. With real new[]
implementation this causes a crash. What's interesting: if we use a constant as
the size of array, it works fine.
== Environment:
Apple's build of clang from XCode 4.0.2 is used. Here's "clang++ --version"'s
output:
Apple clang version 2.0 (tags/Apple/clang-139) (based on LLVM 2.9svn)
Target: x86_64-apple-darwin10
Thread model: posix
The bug appears only on armv6 target architecture — I'm executing the app on
iPhone 2G with iOS 3.1.3. Everything is fine on armv7 devices.
Here's the command line used by XCode:
/Xcode4/Platforms/iPhoneOS.platform/Developer/usr/bin/clang -x c++ -arch armv6
-fmessage-length=0 -fdiagnostics-print-source-range-info
-fdiagnostics-show-category=id -fdiagnostics-parseable-fixits -Wno-trigraphs
-fpascal-strings -O0 -Wreturn-type -Wparentheses -Wswitch -Wno-unused-parameter
-Wunused-variable -Wunused-value -DDEBUG -isysroot
/Xcode4/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.3.sdk -gdwarf-2
-fvisibility-inlines-hidden -mthumb -miphoneos-version-min=3.0 -iquote
/Users/fourdman/Library/Developer/Xcode/DerivedData/newop-ccwnmiceftmdgfeedfcpbcaktxjp/Build/Intermediates/newop.build/Debug-iphoneos/newop.build/newop-generated-files.hmap
-I/Users/fourdman/Library/Developer/Xcode/DerivedData/newop-ccwnmiceftmdgfeedfcpbcaktxjp/Build/Intermediates/newop.build/Debug-iphoneos/newop.build/newop-own-target-headers.hmap
-I/Users/fourdman/Library/Developer/Xcode/DerivedData/newop-ccwnmiceftmdgfeedfcpbcaktxjp/Build/Intermediates/newop.build/Debug-iphoneos/newop.build/newop-all-target-headers.hmap
-iquote
/Users/fourdman/Library/Developer/Xcode/DerivedData/newop-ccwnmiceftmdgfeedfcpbcaktxjp/Build/Intermediates/newop.build/Debug-iphoneos/newop.build/newop-project-headers.hmap
-I/Users/fourdman/Library/Developer/Xcode/DerivedData/newop-ccwnmiceftmdgfeedfcpbcaktxjp/Build/Products/Debug-iphoneos/include
-I/Users/fourdman/Library/Developer/Xcode/DerivedData/newop-ccwnmiceftmdgfeedfcpbcaktxjp/Build/Intermediates/newop.build/Debug-iphoneos/newop.build/DerivedSources/armv6
-I/Users/fourdman/Library/Developer/Xcode/DerivedData/newop-ccwnmiceftmdgfeedfcpbcaktxjp/Build/Intermediates/newop.build/Debug-iphoneos/newop.build/DerivedSources
-F/Users/fourdman/Library/Developer/Xcode/DerivedData/newop-ccwnmiceftmdgfeedfcpbcaktxjp/Build/Products/Debug-iphoneos
-c /Users/fourdman/Documents/Projects/Yandex/newop/newop/main.cpp -o
/Users/fourdman/Library/Developer/Xcode/DerivedData/newop-ccwnmiceftmdgfeedfcpbcaktxjp/Build/Intermediates/newop.build/Debug-iphoneos/newop.build/Objects-normal/armv6/main.o
--
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