Bug 227941 - clang assertion when compiling C++ code with -fblocks
Summary: clang assertion when compiling C++ code with -fblocks
Status: Open
Alias: None
Product: Base System
Classification: Unclassified
Component: bin (show other bugs)
Version: 11.1-RELEASE
Hardware: amd64 Any
: --- Affects Some People
Assignee: Dimitry Andric
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-05-03 01:09 UTC by neal
Modified: 2018-05-03 17:29 UTC (History)
2 users (show)

See Also:


Attachments
llvm crash output (178.22 KB, application/octet-stream)
2018-05-03 13:14 UTC, neal
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description neal 2018-05-03 01:09:57 UTC
Using c++ to compile specific code crashes the compiler.
The compiler then spits out instructions to include files, and submit a bug.
I searched for "llvm crash" and didn't get any hits.

---- llvm output snap shot ----

(516 / 16) [~/src/vs.git/t2]$: gmake clean test
rm -f prog *.core  main.o main.d
c++ -Wno-unused -MP -MD -std=c++11 -g3 -ggdb -fblocks -I. -I/usr/local/include -c main.cpp -o main.o
c++: error: unable to execute command: Segmentation fault (core dumped)
c++: error: clang frontend command failed due to signal (use -v to see invocation)
FreeBSD clang version 4.0.0 (tags/RELEASE_400/final 297347) (based on LLVM 4.0.0)
Target: x86_64-unknown-freebsd11.1
Thread model: posix
InstalledDir: /usr/bin
c++: note: diagnostic msg: PLEASE submit a bug report to https://bugs.freebsd.org/submit/ and include the crash backtrace, preprocessed source, and associated run script.
c++: note: diagnostic msg:
********************

PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
Preprocessed source(s) and associated run script(s) are located at:
c++: note: diagnostic msg: /tmp/main-8ed6cc.cpp
c++: note: diagnostic msg: /tmp/main-8ed6cc.sh
c++: note: diagnostic msg:

********************
gmake: *** [Makefile:72: main.o] Error 254
(neal@xxxx.xxxxxxx.com) 19:13:00
(518 / 18) [~/src/vs.git/t2]$: uname -a
FreeBSD xxxx.xxxxxxx.com 11.1-RELEASE-p4 FreeBSD 11.1-RELEASE-p4 #0: Tue Nov 14 06:12:40 UTC 2017     root@amd64-builder.daemonology.net:/usr/obj/usr/src/sys/GENERIC  amd64
(neal@xxxx.xxxxxxx.com) 19:52:08
(519 / 19) [~/src/vs.git/t2]$: 


--- end output snap shot ---
Comment 1 neal 2018-05-03 01:12:02 UTC
Also, forgot to mention, this same code also crashes llvm on Darwin, so a radar:39926584 has also been reported by me.
Comment 2 Jan Beich freebsd_committer freebsd_triage 2018-05-03 03:30:26 UTC
(In reply to neal from comment #0)
> Preprocessed source(s) and associated run script(s) are located at:
> c++: note: diagnostic msg: /tmp/main-8ed6cc.cpp
> c++: note: diagnostic msg: /tmp/main-8ed6cc.sh

Maybe attach main.cpp or compiler preprocessed source.
Comment 3 neal 2018-05-03 13:14:49 UTC
Created attachment 193022 [details]
llvm crash output

minus the llvm .core file, it's bigger than allowed.
Comment 4 neal 2018-05-03 13:16:22 UTC
Sorry about that.
I missed that the attachment with the .core file didn't make it because of size.
Comment 5 Dimitry Andric freebsd_committer freebsd_triage 2018-05-03 17:17:22 UTC
I can reproduce, also with newer versions of clang.  If assertions are enabled, it gives:

Assertion failed: (isa<X>(Val) && "cast<Ty>() argument of incompatible type!"), function cast, file /usr/src/contrib/llvm/include/llvm/Support/Casting.h, line 255.

Minimized test case:

// clang -cc1 -triple x86_64-- -S -fblocks bug227941-min.cpp
class a {
public:
  template <class b> a(b);
};
class {
public:
  int c(a);
} d;
void f() {
  __attribute__((__blocks__(byref))) int e = d.c([] {});
}

Submitted upstream as: https://bugs.llvm.org/show_bug.cgi?id=37328