Bug 66504

Summary: ICE using C++ exceptions in Objective-C++
Product: gcc Reporter: Braden Obrzut <admin>
Component: objc++Assignee: Not yet assigned to anyone <unassigned>
Status: RESOLVED DUPLICATE    
Severity: major CC: egallager
Priority: P3 Keywords: EH
Version: 5.1.0   
Target Milestone: ---   
Host: Target:
Build: Known to work: 4.2.1, 4.5.4, 4.7.4, 4.8.5, 5.5.0, 6.4.0, 7.2.0
Known to fail: 4.6.4, 4.9.2, 8.0 Last reconfirmed: 2017-07-23 00:00:00
Attachments: Minimal example

Description Braden Obrzut 2015-06-11 11:14:46 UTC
Created attachment 35756 [details]
Minimal example

A rather simple program using C++ exceptions in Objective-C++ can generate an ICE.

exceptionice.mm: In function 'void Problem()':
exceptionice.mm:1:6: internal compiler error: in objc_eh_runtime_type, at objc/objc-next-runtime-abi-01.c:2804
 void Problem()
      ^

Compiled on Mac OS X 10.4 on a PowerMac G4 with the following configuration:

CC=gcc-4.2 CXX=g++-4.2 AS=/opt/cctools/usr/bin/as AS_FOR_TARGET=/opt/cctools/usr/bin/as ../GCC/configure --prefix=/opt/gcc/5 --disable-nls --enable-languages=c,c++,objc,obj-c++,lto --disable-multilib --with-dwarf2

Command line used to get the error is:

/opt/gcc/5/bin/g++ exceptionice.mm
Comment 1 Eric Gallager 2017-07-23 21:00:53 UTC
Confirmed; message I get now with trunk is:

$ /usr/local/bin/g++ -c 35756.mm
during GIMPLE pass: eh
35756.mm: In function ‘void Problem()’:
35756.mm:1:6: internal compiler error: in objc_eh_runtime_type, at objc/objc-next-runtime-abi-01.c:2791
 void Problem()
      ^~~~~~~
libbacktrace could not find executable to open
Please submit a full bug report,
with preprocessed source if appropriate.
See <https://gcc.gnu.org/bugs/> for instructions.

Attaching gdb to get a backtrace, I get:

Breakpoint 2, 0x00fb3c74 in internal_error ()
(gdb) bt
#0  0x00fb3c74 in internal_error ()
warning: .o file "/private/var/root/gcc-git/my_oddly_named_builddir/./mpfr/src/.libs/libmpfr.a(mpfr-gmp.o)" more recent than executable timestamp
#1  0x014e9561 in fancy_abort ()
#2  0x012db91c in objc_eh_runtime_type ()
#3  0x007b571b in add_type_for_runtime ()
#4  0x007b57ab in gen_eh_region_catch ()
#5  0x00c676c1 in lower_eh_constructs_1 ()
#6  0x00c68deb in (anonymous namespace)::pass_lower_eh::execute ()
#7  0x00af3550 in execute_one_pass ()
#8  0x00af3eb9 in execute_pass_list_1 ()
#9  0x00af3f0e in execute_pass_list ()
#10 0x006bed49 in cgraph_node::analyze ()
#11 0x006c1d3d in analyze_functions ()
#12 0x006c2c42 in symbol_table::finalize_compilation_unit ()
#13 0x00bee32a in compile_file ()
#14 0x01b02420 in toplev::main ()
#15 0x01b03a34 in main ()

I'll have to rebuild with debug info to get a better backtrace.
Comment 2 Eric Gallager 2018-01-27 15:53:15 UTC
Huh, I tested this testcase with more versions of gcc, and it works with all the versions I have installed from MacPorts, but still fails with the latest version I built myself... maybe it's a difference in configure options? Although I try to keep mine pretty similar to those that MacPorts uses...
Comment 3 Eric Gallager 2018-10-28 17:00:36 UTC
(In reply to Eric Gallager from comment #1)
> Confirmed; message I get now with trunk is:
> 
> $ /usr/local/bin/g++ -c 35756.mm
> during GIMPLE pass: eh
> 35756.mm: In function ‘void Problem()’:
> 35756.mm:1:6: internal compiler error: in objc_eh_runtime_type, at
> objc/objc-next-runtime-abi-01.c:2791
>  void Problem()
>       ^~~~~~~
> libbacktrace could not find executable to open
> Please submit a full bug report,
> with preprocessed source if appropriate.
> See <https://gcc.gnu.org/bugs/> for instructions.
> 
> Attaching gdb to get a backtrace, I get:
> 
> Breakpoint 2, 0x00fb3c74 in internal_error ()
> (gdb) bt
> #0  0x00fb3c74 in internal_error ()
> warning: .o file
> "/private/var/root/gcc-git/my_oddly_named_builddir/./mpfr/src/.libs/libmpfr.
> a(mpfr-gmp.o)" more recent than executable timestamp
> #1  0x014e9561 in fancy_abort ()
> #2  0x012db91c in objc_eh_runtime_type ()
> #3  0x007b571b in add_type_for_runtime ()
> #4  0x007b57ab in gen_eh_region_catch ()
> #5  0x00c676c1 in lower_eh_constructs_1 ()
> #6  0x00c68deb in (anonymous namespace)::pass_lower_eh::execute ()
> #7  0x00af3550 in execute_one_pass ()
> #8  0x00af3eb9 in execute_pass_list_1 ()
> #9  0x00af3f0e in execute_pass_list ()
> #10 0x006bed49 in cgraph_node::analyze ()
> #11 0x006c1d3d in analyze_functions ()
> #12 0x006c2c42 in symbol_table::finalize_compilation_unit ()
> #13 0x00bee32a in compile_file ()
> #14 0x01b02420 in toplev::main ()
> #15 0x01b03a34 in main ()
> 
> I'll have to rebuild with debug info to get a better backtrace.

Actually looking at the backtrace makes me think this is a dup of bug 61759

*** This bug has been marked as a duplicate of bug 61759 ***