Quuxplusone / LLVMBugzillaTest

0 stars 0 forks source link

Assertion failed: (Val && "isa<> used on a null pointer") on ambiguous constructor call in ObjC++ mode #18836

Open Quuxplusone opened 10 years ago

Quuxplusone commented 10 years ago
Bugzilla Link PR18837
Status NEW
Importance P normal
Reported by warp.grrr@gmx.com
Reported on 2014-02-14 07:58:45 -0800
Last modified on 2014-02-14 09:42:01 -0800
Version 3.3
Hardware All All
CC jonathan.sauer@gmx.de, llvm-bugs@lists.llvm.org
Fixed by commit(s)
Attachments file_18837.txt (5100 bytes, text/plain)
Blocks
Blocked by
See also
clang crashes with a segmentation fault when parsing an Objective-C++ file
(.mm) containing an ambiguous constructor call using an initializer list
syntax. (Curiously, it does not crash when compiling the same code in C++ mode,
instead giving the proper error message.)

Put the following code eg. in a test.mm file and then compile with
clang++ -std=c++11 test.mm

//--------------------------------------------
struct TestStruct { float x, y; };

class Test
{
 public:
    Test(TestStruct) {}
    Test(float, float) {}
};

Test test({ 0, 0 });
//--------------------------------------------

Clang prints:

Stack dump:
0.  Program arguments: (omitted here)
1.  test.mm:12:24: current parser token ';'
2.  test.mm:11:1: parsing function body 'foo'
3.  test.mm:11:1: in compound statement ('{}')
clang: error: unable to execute command: Segmentation fault: 11

Confirmed to happen with:

Apple LLVM version 5.0 (clang-500.2.79) (based on LLVM 3.3svn)
Target: x86_64-apple-darwin13.0.0

and:

Debian clang version 3.3-16 (branches/release_33) (based on LLVM 3.3)
Target: x86_64-pc-linux-gnu

The full invocation in the former case (as reported by clang) is:

/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang
-cc1 -triple x86_64-apple-macosx10.9.0 -emit-obj -mrelax-all -disable-free -
disable-llvm-verifier -main-file-name test.mm -mrelocation-model pic -pic-level
2 -mdisable-fp-elim -masm-verbose -munwind-tables -target-cpu core2 -target-
linker-version 224.1 -stdlib=libc++ -std=c++11 -fdeprecated-macro -ferror-limit
19 -fmessage-length 80 -stack-protector 1 -mstackrealign -fblocks -fobjc-
runtime=macosx-10.9.0 -fobjc-dispatch-method=mixed -fobjc-default-synthesize-
properties -fencode-extended-block-signature -fobjc-exceptions -fcxx-exceptions
-fexceptions -fdiagnostics-show-option -fcolor-diagnostics -x objective-c++
test-MNOZUN.mm
Quuxplusone commented 10 years ago

Attached file_18837.txt (5100 bytes, text/plain): Log of clang run

Quuxplusone commented 10 years ago

Oops, you are right. It was from a version of the example where object was being created inside a foo() function. I simplified the example (because I noticed the function was not needed), but forgot to copy-paste the stack dump from the modified version.