Bug 96097 - ICE in dependent_type_p, at cp/pt.c:26326
Summary: ICE in dependent_type_p, at cp/pt.c:26326
Status: NEW
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 10.1.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: ice-on-valid-code
: 95931 97624 (view as bug list)
Depends on:
Blocks:
 
Reported: 2020-07-07 16:21 UTC by Michael Bruck
Modified: 2021-11-28 15:58 UTC (History)
7 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail: 10.1.0, 11.0
Last reconfirmed: 2021-07-27 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Michael Bruck 2020-07-07 16:21:52 UTC
https://gcc.godbolt.org/z/WVUAy5

Same error location as PR95931, but very different test case with valid code (probably).

<source>: In function 'void test()':
<source>:17:22: internal compiler error: in dependent_type_p, at cp/pt.c:26343
   17 |     func<Y<X, 0>, Y>();
      |                      ^

Fails with -std=c++17 at least since gcc5.1

---
template <
    typename A,
    template <typename T, typename T::typeX> typename TA>
auto func()
{
    return TA<typename A::typeY, 0>{};
}

struct X { using typeX = int; };

template <typename T, int>
// template <typename T, typename T::typeX>  // works
struct Y { using typeY = T; };

void test()
{
    func<Y<X, 0>, Y>();
}
---
Comment 1 Michael Bruck 2020-07-07 16:25:26 UTC
trunk:
internal compiler error: in dependent_type_p, at cp/pt.c:26326

10.1:
internal compiler error: in dependent_type_p, at cp/pt.c:26343
Comment 2 Martin Liška 2020-07-08 07:27:51 UTC
Confirmed, clang accepts the code. GCC ICEs for all revisions.
Comment 3 Haoxin Tu 2020-07-08 08:11:28 UTC
(In reply to Martin Liška from comment #2)
> Confirmed, clang accepts the code. GCC ICEs for all revisions.

Hi,

I just realized I have reported an ice-on-invalid version in bug 95931 with the same symptom in the trunk. Maybe you can consider them together.

Thanks,
Haoxin
Comment 4 Marek Polacek 2020-07-08 19:04:12 UTC
Looks like a dup of bug 90782.
Comment 5 Michael Bruck 2020-07-08 23:40:48 UTC
Further simplified code

template <template <typename T, typename T::type> typename>
void func() {}

template <typename, int>
struct Y {};

void test()
{
    func<Y>();
}
Comment 6 Marek Polacek 2020-10-29 15:10:53 UTC
*** Bug 95931 has been marked as a duplicate of this bug. ***
Comment 7 Marek Polacek 2020-10-29 15:12:26 UTC
*** Bug 97624 has been marked as a duplicate of this bug. ***
Comment 8 Marek Polacek 2020-10-29 15:17:45 UTC
Here, make_typename_type is called when tsubsting, i.e. p_t_d is 0, and it calls dependent_scope_p with a dependent type.  We might need ++ptd/--ptd around the call to make_typename_type.