[LLVMbugs] [Bug 22256] New: Constructor with empty initializer list generates code that crashes at runtime
bugzilla-daemon at llvm.org
bugzilla-daemon at llvm.org
Sat Jan 17 18:20:53 PST 2015
http://llvm.org/bugs/show_bug.cgi?id=22256
Bug ID: 22256
Summary: Constructor with empty initializer list generates code
that crashes at runtime
Product: clang
Version: 3.5
Hardware: PC
OS: MacOS X
Status: NEW
Severity: normal
Priority: P
Component: C++
Assignee: unassignedclangbugs at nondot.org
Reporter: evan.exe at gmail.com
CC: dgregor at apple.com, llvmbugs at cs.uiuc.edu
Classification: Unclassified
Created attachment 13699
--> http://llvm.org/bugs/attachment.cgi?id=13699&action=edit
main.cpp
The attached code contains a List<T> wrapper for std::vector<T> and two
constructors, one default constructor and one that takes a
std::initializer_list<T>.
Steps (using latest OS X Command Line Tools, version 6.1):
1. Compile attached file using "clang++ -std=c++11 main.cpp"
2. Run the attached file using "MallocScribble=1 ./a.out"
Expected:
I expect that "auto keys = new List<std::string>({});" and "auto keys = new
List<std::string>();" both create an empty list and both do not crash. Each one
can be tested by commenting that one in and commenting the other one out.
Actual:
The code for the default constructor runs fine but the code for the initializer
list constructor crashes at runtime. It appears the compiler is generating
incorrect code for the initializer list constructor. Poking around the Xcode
debugger reveals that the __begin_ std::vector member is 0 but the __end_
std::vector member is 24, which is sizeof(std::string). The size() method
returns 1 but get(0) crashes.
This code is a reduced test case from a real app. The real app crashes without
any debug options but the reduced code needs MallocScribble=1 to trigger the
crash.
Also logged as rdar://19510408
clang++ --version:
Apple LLVM version 6.0 (clang-600.0.56) (based on LLVM 3.5svn)
Target: x86_64-apple-darwin13.4.0
Thread model: posix
--
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/20150118/46597288/attachment.html>
More information about the llvm-bugs
mailing list