[Bug c++/82099] internal compiler error: in type_throw_all_p, at cp/except.c:1186 when using a function pointer for templated predicate

2021-01-05 Thread mpolacek at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82099

Marek Polacek  changed:

   What|Removed |Added

 Status|ASSIGNED|RESOLVED
 Resolution|--- |FIXED

--- Comment #12 from Marek Polacek  ---
Fixed.

[Bug c++/82099] internal compiler error: in type_throw_all_p, at cp/except.c:1186 when using a function pointer for templated predicate

2021-01-05 Thread cvs-commit at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82099

--- Comment #11 from CVS Commits  ---
The releases/gcc-10 branch has been updated by Marek Polacek
:

https://gcc.gnu.org/g:ff22b4e8d0613170601d28eec9462ea31147c7c7

commit r10-9209-gff22b4e8d0613170601d28eec9462ea31147c7c7
Author: Marek Polacek 
Date:   Tue Jan 5 16:33:07 2021 -0500

c++: ICE with deferred noexcept when deducing targs [PR82099]

In this test we ICE in type_throw_all_p because it got a deferred
noexcept which it shouldn't.  Here's the story:

In noexcept61.C, we call bar, so we perform overload resolution.  When
adding the (only) candidate, we need to deduce template arguments, so
call fn_type_unification as usually.  That deduces U to

  void (*) (int &, int &)

which is correct, but its noexcept-spec is deferred_noexcept.  Then
we call add_function_candidate (bar), wherein we try to create an
implicit conversion sequence for every argument.  Since baz is
of unknown type, we instantiate_type it; it is a TEMPLATE_ID_EXPR
so that calls resolve_address_of_overloaded_function.  But we crash
there, because target_type contains the deferred_noexcept.

So we need to maybe_instantiate_noexcept before we can compare types.
resolve_overloaded_unification seemed like the appropriate spot, now
fn_type_unification produces the function type with its noexcept-spec
instantiated.  This shouldn't go against CWG 1330 because here we
really need to instantiate the noexcept-spec.

This also fixes class-deduction76.C, a dg-ice test I recently added,
therefore this fix also fixes c++/90799, yay.

gcc/cp/ChangeLog:

PR c++/82099
* pt.c (resolve_overloaded_unification): Call
maybe_instantiate_noexcept after instantiating the function
decl.

gcc/testsuite/ChangeLog:

PR c++/82099
* g++.dg/cpp0x/noexcept61.C: New test.

[Bug c++/82099] internal compiler error: in type_throw_all_p, at cp/except.c:1186 when using a function pointer for templated predicate

2021-01-05 Thread cvs-commit at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82099

--- Comment #10 from CVS Commits  ---
The master branch has been updated by Marek Polacek :

https://gcc.gnu.org/g:af362af18f405c34840d820143aa3a94f72fce4d

commit r11-6476-gaf362af18f405c34840d820143aa3a94f72fce4d
Author: Marek Polacek 
Date:   Thu Dec 10 15:00:58 2020 -0500

c++: ICE with deferred noexcept when deducing targs [PR82099]

In this test we ICE in type_throw_all_p because it got a deferred
noexcept which it shouldn't.  Here's the story:

In noexcept61.C, we call bar, so we perform overload resolution.  When
adding the (only) candidate, we need to deduce template arguments, so
call fn_type_unification as usually.  That deduces U to

  void (*) (int &, int &)

which is correct, but its noexcept-spec is deferred_noexcept.  Then
we call add_function_candidate (bar), wherein we try to create an
implicit conversion sequence for every argument.  Since baz is
of unknown type, we instantiate_type it; it is a TEMPLATE_ID_EXPR
so that calls resolve_address_of_overloaded_function.  But we crash
there, because target_type contains the deferred_noexcept.

So we need to maybe_instantiate_noexcept before we can compare types.
resolve_overloaded_unification seemed like the appropriate spot, now
fn_type_unification produces the function type with its noexcept-spec
instantiated.  This shouldn't go against CWG 1330 because here we
really need to instantiate the noexcept-spec.

This also fixes class-deduction76.C, a dg-ice test I recently added,
therefore this fix also fixes c++/90799, yay.

gcc/cp/ChangeLog:

PR c++/82099
* pt.c (resolve_overloaded_unification): Call
maybe_instantiate_noexcept after instantiating the function
decl.

gcc/testsuite/ChangeLog:

PR c++/82099
* g++.dg/cpp1z/class-deduction76.C: Remove dg-ice.
* g++.dg/cpp0x/noexcept61.C: New test.

[Bug c++/82099] internal compiler error: in type_throw_all_p, at cp/except.c:1186 when using a function pointer for templated predicate

2020-12-09 Thread mpolacek at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82099

Marek Polacek  changed:

   What|Removed |Added

 CC||mpolacek at gcc dot gnu.org
   Assignee|unassigned at gcc dot gnu.org  |mpolacek at gcc dot 
gnu.org
 Status|NEW |ASSIGNED

--- Comment #9 from Marek Polacek  ---
I have a patch.

[Bug c++/82099] internal compiler error: in type_throw_all_p, at cp/except.c:1186 when using a function pointer for templated predicate

2020-11-10 Thread redi at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82099

Jonathan Wakely  changed:

   What|Removed |Added

 CC||janezz55 at gmail dot com

--- Comment #8 from Jonathan Wakely  ---
*** Bug 97773 has been marked as a duplicate of this bug. ***

[Bug c++/82099] internal compiler error: in type_throw_all_p, at cp/except.c:1186 when using a function pointer for templated predicate

2020-04-07 Thread mpolacek at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82099

Marek Polacek  changed:

   What|Removed |Added

 CC||twelvevolt at yandex dot ru

--- Comment #7 from Marek Polacek  ---
*** Bug 94525 has been marked as a duplicate of this bug. ***

[Bug c++/82099] internal compiler error: in type_throw_all_p, at cp/except.c:1186 when using a function pointer for templated predicate

2020-04-02 Thread ed at catmur dot uk
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82099

Ed Catmur  changed:

   What|Removed |Added

 CC||ed at catmur dot uk

--- Comment #6 from Ed Catmur  ---
Workaround: force computation of noexcept of predicate before it is required:

noexcept(+baz);

or simply

baz;

[Bug c++/82099] internal compiler error: in type_throw_all_p, at cp/except.c:1186 when using a function pointer for templated predicate

2018-04-13 Thread reichelt at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82099

Volker Reichelt  changed:

   What|Removed |Added

   Last reconfirmed|2017-09-04 00:00:00 |2018-4-13
 CC||reichelt at gcc dot gnu.org

--- Comment #5 from Volker Reichelt  ---
On trunk (GCC 8) the testcases of comment #2 and comment #4 only crash with
-std=c++17, but don't crash with -std=c++11 or -std=c++14.

[Bug c++/82099] internal compiler error: in type_throw_all_p, at cp/except.c:1186 when using a function pointer for templated predicate

2017-09-04 Thread jakub at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82099

--- Comment #4 from Jakub Jelinek  ---
Slightly adjusted testcase that better matches what the original had:

template 
void bar (T , T , U u)
{
  u (x, y);
}

template 
void baz (T , T ) noexcept (noexcept (x == y));

void
foo (int x, int y)
{
  bar (x, y, baz);
}

The ICE is always because there is a deferred throw/noexcept spec when we
assert that it is not deferred.

[Bug c++/82099] internal compiler error: in type_throw_all_p, at cp/except.c:1186 when using a function pointer for templated predicate

2017-09-04 Thread jakub at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82099

Jakub Jelinek  changed:

   What|Removed |Added

 CC||jason at gcc dot gnu.org

--- Comment #3 from Jakub Jelinek  ---
Started to ICE with r160298 or so (when noexcept has been implemented).

[Bug c++/82099] internal compiler error: in type_throw_all_p, at cp/except.c:1186 when using a function pointer for templated predicate

2017-09-04 Thread jakub at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82099

Jakub Jelinek  changed:

   What|Removed |Added

 Status|UNCONFIRMED |NEW
   Last reconfirmed||2017-09-04
 CC||jakub at gcc dot gnu.org
 Ever confirmed|0   |1

--- Comment #2 from Jakub Jelinek  ---
Reduced testcase (fails with all of -std=c++{11,14,17}, just the ICE is
different with c++17):
template 
void bar (T x, U u)
{
  u (x);
}

template 
void baz (T t) noexcept (noexcept (t));

void
foo (int x)
{
  bar (x, baz);
}

[Bug c++/82099] internal compiler error: in type_throw_all_p, at cp/except.c:1186 when using a function pointer for templated predicate

2017-09-04 Thread gcc at hazardy dot de
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82099

--- Comment #1 from Björn Schäpers  ---
Created attachment 42117
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=42117=edit
The preprocessed test file.