FS#47329 - [clang] crashes when compile with -std=c++11 -stdlib=libc++

Attached to Project: Arch Linux
Opened by Weitian Leung (timxx) - Friday, 11 December 2015, 07:01 GMT
Last edited by Evangelos Foutras (foutrelis) - Friday, 15 January 2016, 19:56 GMT
Task Type Bug Report
Category Packages: Extra
Status Closed
Assigned To Evangelos Foutras (foutrelis)
Architecture All
Severity High
Priority Normal
Reported Version
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 17
Private No

Details

Description:

After the latest update (3.7.0-6), clang failes compile a simple program like hello world:
#include <iostream>

int main()
{
std::cout << "Hello, world" << std::endl;
return 0;
}

compile with: clang++ -c helloworld.cpp -std=c++11 -stdlib=libc++
It works when remove -std=c++11 or -stdlib=libc++.

Check the attachment for the crashes infomation.

Additional info:
* package version(s)
clang 3.7.0-6
* config and/or log files etc.


Steps to reproduce:
Show as Description
This task depends upon

Closed by  Evangelos Foutras (foutrelis)
Friday, 15 January 2016, 19:56 GMT
Reason for closing:  Fixed
Additional comments about closing:  clang 3.7.1-1
Comment by Florian Scandella (fscan) - Friday, 11 December 2015, 16:38 GMT
same problem here, worked the day before. probably introduced by the g++ compat patch?

Comment by Marc A. Kastner (mkasu) - Saturday, 12 December 2015, 17:36 GMT
same problem here. also happens for -std=c++14.
Comment by David Renshaw (dwrensha) - Monday, 14 December 2015, 21:27 GMT
I'm also seeing crashes with clang++, although the "hello world" program above works fine for me.
I reported more details in a separate bug (https://bugs.archlinux.org/task/47375 ), which was closed as a duplicate of the present bug.

EDIT: Ah, the "hello world" program does indeed crash once I do `sudo pacman -S libc++`. Before that it just failed to compile with the `-stdlib=libc++` option.
Comment by Syl (Bouh) - Saturday, 19 December 2015, 06:32 GMT
On my machine, it happens only when using the the libc++ ABI. With the GNU libstdc++ ABI, everything is fine (whether c++03, c++11 or c++14 does not seem to matter for me).
Comment by Tavian Barnes (tavianator) - Tuesday, 05 January 2016, 17:58 GMT
The crash happens in code from clang-3.7.0-add-gcc-abi-tag-support.patch, specifically ItaniumMangle.cpp. The call chain is

AbiTagState::write (ItaniumMangle.cpp:361) <-- ND is nullptr here, crash on ND->getCanonicalDecl()
writeAbiTags (ItaniumMangle.cpp:654)
mangleUnresolvedPrefix (ItaniumMangle.cpp:1122) <-- passes qualifier->getAsNamespaceAlias() as ND
mangleUnresolvedName (ItaniumMangle.cpp:1137)
mangleExpression (ItaniumMangle.cpp:3548)
mangleExpression (ItaniumMangle.cpp:3490)
mangleExpression (ItaniumMangle.cpp:3490)
mangleExpression (ItaniumMangle.cpp:3420)
mangleExpression (ItaniumMangle.cpp:3495)
mangleExpression (ItaniumMangle.cpp:3421)
mangleTemplateArg (ItaniumMangle.cpp:3867)
mangleTemplateArgs (ItaniumMangle.cpp:3823)
...

Looks like some bad copy-pasta in that patch, at line 1122 we're in "case NestedNameSpecifier::Identifier" so getAsNamespaceAlias() makes no sense. Based on the other calls, I think just "writeAbiTags(qualifier)" would be correct. I'm rebuilding now to test.
Comment by Tavian Barnes (tavianator) - Tuesday, 05 January 2016, 18:33 GMT
Okay writeAbiTags(qualifier) doesn't compile, but writeAbiTags(qualifier->getAsNamespaceAlias()) is still wrong.
Comment by Nikolay Bogoychev (Dheart) - Tuesday, 05 January 2016, 18:43 GMT
There's a bug on llvm's bug tracker that got closed as invalid. It seems to be an Arch only issue: https://llvm.org/bugs/show_bug.cgi?id=25969
This also prevents Unreal engine from compiling.

Loading...