Bug 95675 - [8/9/10/11 Regression] internal compiler error: in build_over_call
Summary: [8/9/10/11 Regression] internal compiler error: in build_over_call
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 11.0
: P2 normal
Target Milestone: 9.4
Assignee: Jason Merrill
URL:
Keywords: ice-checking, ice-on-valid-code
: 96576 97962 99016 (view as bug list)
Depends on:
Blocks:
 
Reported: 2020-06-14 23:35 UTC by Rafael Avila de Espindola
Modified: 2021-08-05 04:25 UTC (History)
8 users (show)

See Also:
Host:
Target:
Build:
Known to work: 6.4.0
Known to fail: 10.1.0, 8.4.0, 9.3.0
Last reconfirmed: 2020-06-15 00:00:00


Attachments
testcase (4.11 KB, text/plain)
2020-06-14 23:35 UTC, Rafael Avila de Espindola
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Rafael Avila de Espindola 2020-06-14 23:35:11 UTC
Created attachment 48729 [details]
testcase

With current master (06712fc68dc9843d9af7c7ac10047f49d305ad76), running

g++ -S test.ii  -std=c++20

In the attached file causes

test.ii:511:41: internal compiler error: in build_over_call, at cp/call.c:8971 

g++ 9 has no problems with it.
Comment 1 Rafael Avila de Espindola 2020-06-14 23:35:53 UTC
Sorry, gcc *10* has no problem with it.
Comment 2 Martin Liška 2020-06-15 06:55:50 UTC
With -std=c++2a -fconcepts it started with r9-6542-gf869f40780836d17.
It was rejected before that.
Comment 3 Patrick Palka 2020-07-07 14:58:18 UTC
Here's a reduced testcase that ICEs when compiled with -std=c++17 since r7-3599 (when GCC is configured with --enable-checking=yes):

$ cat 95675.C
struct a {};
template <typename> struct b;
template <typename bq, typename br> struct b<bq(br)> {
  decltype(bq()(br())) c;
};
struct e {
  operator a();
};
b<e (*(e))(a)> d;

$ g++ -std=c++17 95675.C
95675.C: In instantiation of ‘struct b<e (*(e))(a)>’:                                          
95675.C:9:16:   required from here                                                             
95675.C:4:16: internal compiler error: in build_over_call, at cp/call.c:8945                   
    4 |   decltype(bq()(br())) c;                                                              
      |            ~~~~^~~~~~
Comment 4 Patrick Palka 2020-07-22 15:49:14 UTC
Here's a non-template testcase that ICEs from the same assert in build_over_call (with -std=c++17, --enable-checking=yes):

struct b {};
b operator|(b, b) { return {}; }
b e, f, g;
using h = decltype(e | f | g);
Comment 5 Patrick Palka 2020-08-12 12:25:59 UTC
*** Bug 96576 has been marked as a duplicate of this bug. ***
Comment 6 Marek Polacek 2020-10-16 00:00:47 UTC
Comment 4 test started with r240845.
Comment 7 Patrick Palka 2021-02-10 15:03:44 UTC
*** Bug 99016 has been marked as a duplicate of this bug. ***
Comment 8 GCC Commits 2021-03-03 13:47:39 UTC
The master branch has been updated by Jason Merrill <jason@gcc.gnu.org>:

https://gcc.gnu.org/g:74aee6d20872e8d87558eb5bf601042e3ed3fb2a

commit r11-7481-g74aee6d20872e8d87558eb5bf601042e3ed3fb2a
Author: Jason Merrill <jason@redhat.com>
Date:   Tue Mar 2 23:59:00 2021 -0500

    c++: C++17 and decltype of multi-operator expression [PR95675]
    
    A call that is the immediate operand of decltype has special semantics: no
    temporary is produced, so it's OK for the return type to be e.g. incomplete.
    But we were treating (e | f) the same way, which confused overload
    resolution when we then tried to evaluate ... | g.
    
    Fixed by making build_temp do what its name says, and force the C++17
    temporary materialization conversion.
    
    gcc/cp/ChangeLog:
    
            PR c++/95675
            * call.c (build_temp): Wrap a CALL_EXPR in a TARGET_EXPR
            if it didn't get one before.
    
    gcc/testsuite/ChangeLog:
    
            PR c++/95675
            * g++.dg/cpp0x/decltype-call5.C: New test.
            * g++.dg/cpp0x/decltype-call6.C: New test.
Comment 9 GCC Commits 2021-03-04 04:49:29 UTC
The releases/gcc-10 branch has been updated by Jason Merrill <jason@gcc.gnu.org>:

https://gcc.gnu.org/g:371c7a82833df5d84392838cf2bf95b4da88655c

commit r10-9414-g371c7a82833df5d84392838cf2bf95b4da88655c
Author: Jason Merrill <jason@redhat.com>
Date:   Tue Mar 2 23:59:00 2021 -0500

    c++: C++17 and decltype of multi-operator expression [PR95675]
    
    A call that is the immediate operand of decltype has special semantics: no
    temporary is produced, so it's OK for the return type to be e.g. incomplete.
    But we were treating (e | f) the same way, which confused overload
    resolution when we then tried to evaluate ... | g.
    
    Fixed by making build_temp do what its name says, and force the C++17
    temporary materialization conversion.
    
    gcc/cp/ChangeLog:
    
            PR c++/95675
            * call.c (build_temp): Wrap a CALL_EXPR in a TARGET_EXPR
            if it didn't get one before.
    
    gcc/testsuite/ChangeLog:
    
            PR c++/95675
            * g++.dg/cpp0x/decltype-call5.C: New test.
            * g++.dg/cpp0x/decltype-call6.C: New test.
Comment 10 GCC Commits 2021-03-04 05:13:46 UTC
The releases/gcc-9 branch has been updated by Jason Merrill <jason@gcc.gnu.org>:

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

commit r9-9264-ge90b052caf74dcc7529e6b2cc0b0688eebf53c74
Author: Jason Merrill <jason@redhat.com>
Date:   Tue Mar 2 23:59:00 2021 -0500

    c++: C++17 and decltype of multi-operator expression [PR95675]
    
    A call that is the immediate operand of decltype has special semantics: no
    temporary is produced, so it's OK for the return type to be e.g. incomplete.
    But we were treating (e | f) the same way, which confused overload
    resolution when we then tried to evaluate ... | g.
    
    Fixed by making build_temp do what its name says, and force the C++17
    temporary materialization conversion.
    
    gcc/cp/ChangeLog:
    
            PR c++/95675
            * call.c (build_temp): Wrap a CALL_EXPR in a TARGET_EXPR
            if it didn't get one before.
    
    gcc/testsuite/ChangeLog:
    
            PR c++/95675
            * g++.dg/cpp0x/decltype-call5.C: New test.
            * g++.dg/cpp0x/decltype-call6.C: New test.
Comment 11 Jason Merrill 2021-03-25 16:11:59 UTC
Fixed for 9.4/10.3/11.
Comment 12 Patrick Palka 2021-04-02 13:30:30 UTC
*** Bug 97962 has been marked as a duplicate of this bug. ***