Bug 93345 - [10 Regression] ICE in nothrow_spec_p, at cp/except.c:1247
Summary: [10 Regression] ICE in nothrow_spec_p, at cp/except.c:1247
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 10.0
: P1 normal
Target Milestone: 10.0
Assignee: Jason Merrill
URL:
Keywords: ice-on-valid-code
Depends on:
Blocks:
 
Reported: 2020-01-21 02:17 UTC by Arseny Solokha
Modified: 2020-01-24 23:20 UTC (History)
6 users (show)

See Also:
Host:
Target:
Build:
Known to work: 9.2.0
Known to fail: 10.0
Last reconfirmed: 2020-01-21 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Arseny Solokha 2020-01-21 02:17:16 UTC
g++-10.0.0-alpha20200119 snapshot (g:3684bbb022cd75da55e1457673f269980aa12cdf) ICEs when compiling the following testcase reduced from test/CodeGenCXX/instantiate-temporaries.cpp from the clang 9.0.1 test suite:

struct ln {
  ~ln ();
};

struct ry {
  ln kj;
};

template<typename GC>
void
dz ()
{
  ry{};
}

% g++-10.0.0-alpha20200119 -c qziipxqi.cpp
qziipxqi.cpp: In function 'void dz()':
qziipxqi.cpp:13:6: internal compiler error: in nothrow_spec_p, at cp/except.c:1247
   13 |   ry{};
      |      ^
0x61ed48 nothrow_spec_p(tree_node const*)
	/var/tmp/portage/sys-devel/gcc-10.0.0_alpha20200119/work/gcc-10-20200119/gcc/cp/except.c:1247
0x92a3e9 check_noexcept_r
	/var/tmp/portage/sys-devel/gcc-10.0.0_alpha20200119/work/gcc-10-20200119/gcc/cp/except.c:1146
0x129d6ea walk_tree_1(tree_node**, tree_node* (*)(tree_node**, int*, void*), void*, hash_set<tree_node*, false, default_hash_traits<tree_node*> >*, tree_node* (*)(tree_node**, int*, tree_node* (*)(tree_node**, int*, void*), void*, hash_set<tree_node*, false, default_hash_traits<tree_node*> >*))
	/var/tmp/portage/sys-devel/gcc-10.0.0_alpha20200119/work/gcc-10-20200119/gcc/tree.c:11954
0x12a12aa walk_tree_without_duplicates_1(tree_node**, tree_node* (*)(tree_node**, int*, void*), void*, tree_node* (*)(tree_node**, int*, tree_node* (*)(tree_node**, int*, void*), void*, hash_set<tree_node*, false, default_hash_traits<tree_node*> >*))
	/var/tmp/portage/sys-devel/gcc-10.0.0_alpha20200119/work/gcc-10-20200119/gcc/tree.c:12310
0x92a09f expr_noexcept_p(tree_node*, int)
	/var/tmp/portage/sys-devel/gcc-10.0.0_alpha20200119/work/gcc-10-20200119/gcc/cp/except.c:1221
0x8e8763 cxx_maybe_build_cleanup(tree_node*, int)
	/var/tmp/portage/sys-devel/gcc-10.0.0_alpha20200119/work/gcc-10-20200119/gcc/cp/decl.c:17405
0xa46c40 build_target_expr
	/var/tmp/portage/sys-devel/gcc-10.0.0_alpha20200119/work/gcc-10-20200119/gcc/cp/tree.c:511
0xa25f44 finish_compound_literal(tree_node*, tree_node*, int, fcl_t)
	/var/tmp/portage/sys-devel/gcc-10.0.0_alpha20200119/work/gcc-10-20200119/gcc/cp/semantics.c:2970
0x986772 cp_parser_functional_cast
	/var/tmp/portage/sys-devel/gcc-10.0.0_alpha20200119/work/gcc-10-20200119/gcc/cp/parser.c:29391
0x99ea48 cp_parser_postfix_expression
	/var/tmp/portage/sys-devel/gcc-10.0.0_alpha20200119/work/gcc-10-20200119/gcc/cp/parser.c:7134
0x9811ea cp_parser_binary_expression
	/var/tmp/portage/sys-devel/gcc-10.0.0_alpha20200119/work/gcc-10-20200119/gcc/cp/parser.c:9508
0x982dce cp_parser_assignment_expression
	/var/tmp/portage/sys-devel/gcc-10.0.0_alpha20200119/work/gcc-10-20200119/gcc/cp/parser.c:9813
0x9831a3 cp_parser_expression
	/var/tmp/portage/sys-devel/gcc-10.0.0_alpha20200119/work/gcc-10-20200119/gcc/cp/parser.c:9981
0x9861e8 cp_parser_expression_statement
	/var/tmp/portage/sys-devel/gcc-10.0.0_alpha20200119/work/gcc-10-20200119/gcc/cp/parser.c:11621
0x9915f3 cp_parser_statement
	/var/tmp/portage/sys-devel/gcc-10.0.0_alpha20200119/work/gcc-10-20200119/gcc/cp/parser.c:11417
0x992e78 cp_parser_statement_seq_opt
	/var/tmp/portage/sys-devel/gcc-10.0.0_alpha20200119/work/gcc-10-20200119/gcc/cp/parser.c:11768
0x992f58 cp_parser_compound_statement
	/var/tmp/portage/sys-devel/gcc-10.0.0_alpha20200119/work/gcc-10-20200119/gcc/cp/parser.c:11718
0x9aaa45 cp_parser_function_body
	/var/tmp/portage/sys-devel/gcc-10.0.0_alpha20200119/work/gcc-10-20200119/gcc/cp/parser.c:22948
0x9aaa45 cp_parser_ctor_initializer_opt_and_function_body
	/var/tmp/portage/sys-devel/gcc-10.0.0_alpha20200119/work/gcc-10-20200119/gcc/cp/parser.c:22999
0x9ade36 cp_parser_function_definition_after_declarator
	/var/tmp/portage/sys-devel/gcc-10.0.0_alpha20200119/work/gcc-10-20200119/gcc/cp/parser.c:28821
Comment 1 Martin Liška 2020-01-21 09:14:28 UTC
Started with r10-6077-gbcfc2227c556f2801a657ce3007374732baa8333.
Comment 2 Khem Raj 2020-01-22 01:36:12 UTC
I started to seeing this as well when building geany on arm
Comment 3 Jan Hubicka 2020-01-22 15:52:41 UTC
This also seems to trigger when building Firefox

[task 2020-01-22T14:50:38.221Z] 14:50:38     INFO -  0x62825b nothrow_spec_p(tree_node const*)
[task 2020-01-22T14:50:38.222Z] 14:50:38     INFO -  	../../gcc-source/gcc/cp/except.c:1247
[task 2020-01-22T14:50:38.224Z] 14:50:38     INFO -  0x6fac7f check_noexcept_r
[task 2020-01-22T14:50:38.225Z] 14:50:38     INFO -  	../../gcc-source/gcc/cp/except.c:1146
[task 2020-01-22T14:50:38.227Z] 14:50:38     INFO -  0xecdb1a walk_tree_1(tree_node**, tree_node* (*)(tree_node**, int*, void*), void*, hash_set<tree_node*, false, default_hash_traits<tree_node*> >*, tree_node* (*)(tree_node**, int*, tree_node* (*)(tree_node**, int*, void*), void*, hash_set<tree_node*, false, default_hash_traits<tree_node*> >*))
[task 2020-01-22T14:50:38.228Z] 14:50:38     INFO -  	../../gcc-source/gcc/tree.c:11954
[task 2020-01-22T14:50:38.230Z] 14:50:38     INFO -  0xecfc5a walk_tree_without_duplicates_1(tree_node**, tree_node* (*)(tree_node**, int*, void*), void*, tree_node* (*)(tree_node**, int*, tree_node* (*)(tree_node**, int*, void*), void*, hash_set<tree_node*, false, default_hash_traits<tree_node*> >*))
[task 2020-01-22T14:50:38.231Z] 14:50:38     INFO -  	../../gcc-source/gcc/tree.c:12310
[task 2020-01-22T14:50:38.233Z] 14:50:38     INFO -  0x6fa9af expr_noexcept_p(tree_node*, int)
[task 2020-01-22T14:50:38.234Z] 14:50:38     INFO -  	../../gcc-source/gcc/cp/except.c:1221
[task 2020-01-22T14:50:38.235Z] 14:50:38     INFO -  0x6d3d4b cxx_maybe_build_cleanup(tree_node*, int)
[task 2020-01-22T14:50:38.236Z] 14:50:38     INFO -  	../../gcc-source/gcc/cp/decl.c:17396
[task 2020-01-22T14:50:38.238Z] 14:50:38     INFO -  0x7c828b build_target_expr
[task 2020-01-22T14:50:38.239Z] 14:50:38     INFO -  	../../gcc-source/gcc/cp/tree.c:511
[task 2020-01-22T14:50:38.241Z] 14:50:38     INFO -  0x7c8402 build_cplus_new(tree_node*, tree_node*, int)
[task 2020-01-22T14:50:38.242Z] 14:50:38     INFO -  	../../gcc-source/gcc/cp/tree.c:717
[task 2020-01-22T14:50:38.242Z] 14:50:38     INFO -  0x672d48 convert_like_real
[task 2020-01-22T14:50:38.242Z] 14:50:38     INFO -  	../../gcc-source/gcc/cp/call.c:7446
[task 2020-01-22T14:50:38.242Z] 14:50:38     INFO -  0x672c05 convert_like_real
[task 2020-01-22T14:50:38.243Z] 14:50:38     INFO -  	../../gcc-source/gcc/cp/call.c:7576
[task 2020-01-22T14:50:38.243Z] 14:50:38     INFO -  0x6821d8 build_conditional_expr_1
[task 2020-01-22T14:50:38.243Z] 14:50:38     INFO -  	../../gcc-source/gcc/cp/call.c:5401
[task 2020-01-22T14:50:38.243Z] 14:50:38     INFO -  0x68282c build_conditional_expr(op_location_t const&, tree_node*, tree_node*, tree_node*, int)
[task 2020-01-22T14:50:38.243Z] 14:50:38     INFO -  	../../gcc-source/gcc/cp/call.c:5694
[task 2020-01-22T14:50:38.243Z] 14:50:38     INFO -  0x7d3f8b build_x_conditional_expr(unsigned int, tree_node*, tree_node*, tree_node*, int)
[task 2020-01-22T14:50:38.243Z] 14:50:38     INFO -  	../../gcc-source/gcc/cp/typeck.c:6964
[task 2020-01-22T14:50:38.243Z] 14:50:38     INFO -  0x73cfba cp_parser_assignment_expression
[task 2020-01-22T14:50:38.243Z] 14:50:38     INFO -  	../../gcc-source/gcc/cp/parser.c:9817
[task 2020-01-22T14:50:38.243Z] 14:50:38     INFO -  0x73d182 cp_parser_expression
[task 2020-01-22T14:50:38.243Z] 14:50:38     INFO -  	../../gcc-source/gcc/cp/parser.c:9981
[task 2020-01-22T14:50:38.243Z] 14:50:38     INFO -  0x74a21b cp_parser_jump_statement
[task 2020-01-22T14:50:38.243Z] 14:50:38     INFO -  	../../gcc-source/gcc/cp/parser.c:13025
[task 2020-01-22T14:50:38.244Z] 14:50:38     INFO -  0x74a21b cp_parser_statement
[task 2020-01-22T14:50:38.244Z] 14:50:38     INFO -  	../../gcc-source/gcc/cp/parser.c:11295
[task 2020-01-22T14:50:38.244Z] 14:50:38     INFO -  0x74b4f8 cp_parser_statement_seq_opt
[task 2020-01-22T14:50:38.244Z] 14:50:38     INFO -  	../../gcc-source/gcc/cp/parser.c:11768
[task 2020-01-22T14:50:38.244Z] 14:50:38     INFO -  0x74b5b0 cp_parser_compound_statement
[task 2020-01-22T14:50:38.244Z] 14:50:38     INFO -  	../../gcc-source/gcc/cp/parser.c:11718
[task 2020-01-22T14:50:38.244Z] 14:50:38     INFO -  0x76570d cp_parser_implicitly_scoped_statement
[task 2020-01-22T14:50:38.244Z] 14:50:38     INFO -  	../../gcc-source/gcc/cp/parser.c:13144
Comment 4 David Binderman 2020-01-23 13:15:29 UTC
I also see this error when compiling Fedora package csdiff.

Reduced test case available on request.
Comment 5 GCC Commits 2020-01-23 18:11:54 UTC
The master branch has been updated by Jason Merrill <jason@gcc.gnu.org>:

https://gcc.gnu.org/g:20afdcd36982752ba012960b862e9be7154b1274

commit r10-6183-g20afdcd36982752ba012960b862e9be7154b1274
Author: Jason Merrill <jason@redhat.com>
Date:   Thu Jan 23 12:32:02 2020 -0500

    c++: Fix ICE with defaulted destructor and template.
    
    In a template we don't instantiate a deferred noexcept-spec, and we don't
    need it because we aren't going to do anything with the value of
    throwing_cleanup in a template anyway.
    
    	PR c++/93345 - ICE with defaulted dtor and template.
    	PR c++/33799
    	* decl.c (cxx_maybe_build_cleanup): Don't try to set
    	throwing_cleanup in a template.
Comment 6 Jason Merrill 2020-01-23 18:12:32 UTC
Fixed.
Comment 7 gcc-bugs 2020-01-24 23:20:57 UTC
Hi Jason Merrill,

I have the following gcc-9 code:

```
template <typename> concept bool a = true;
template <int> struct b {};
template <typename g> using c = b<a<g>>;
struct h {
  template <typename g> auto operator()(g) noexcept(noexcept(c<g>{})) {}
};
template <typename d> concept bool e = requires(d f) { h{}(f); };
static_assert(e<int>);
```

that ICEs at the same location:

```
> g++ -std=c++17 -fconcepts -c ice.cpp  
ice.cpp:7:59: internal compiler error: in nothrow_spec_p, at cp/except.c:1247
    7 | template <typename d> concept bool e = requires(d f) { h{}(f); };
      |                                                        ~~~^~~
Please submit a full bug report,
with preprocessed source if appropriate.
See <https://bugs.archlinux.org/> for instructions.
```

Is this a dupe of this? or should I create a new issue? A gcc-10 build of mine seems to compile it. So this patch might need to be backported to gcc9.

```
> g++ -v

Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-pc-linux-gnu/9.2.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: /build/gcc/src/gcc/configure --prefix=/usr --libdir=/usr/lib --libexecdir=/usr/lib --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=https://bugs.archlinux.org/ --enable-languages=c,c++,ada,fortran,go,lto,objc,obj-c++,d --enable-shared --enable-threads=posix --with-system-zlib --with-isl --enable-__cxa_atexit --disable-libunwind-exceptions --enable-clocale=gnu --disable-libstdcxx-pch --disable-libssp --enable-gnu-unique-object --enable-linker-build-id --enable-lto --enable-plugin --enable-install-libiberty --with-linker-hash-style=gnu --enable-gnu-indirect-function --enable-multilib --disable-werror --enable-checking=release --enable-default-pie --enable-default-ssp --enable-cet=auto gdc_include_dir=/usr/include/dlang/gdc
Thread model: posix
gcc version 9.2.0 (GCC) 
```