Bug 102123 - [11 Regression] Internal Compiler Error occurs during template deduction in use with templates as template parameters
Summary: [11 Regression] Internal Compiler Error occurs during template deduction in u...
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 12.0
: P2 normal
Target Milestone: 11.3
Assignee: Jason Merrill
URL:
Keywords: ice-on-valid-code, rejects-valid
Depends on:
Blocks:
 
Reported: 2021-08-30 03:00 UTC by friedkeenan
Modified: 2022-03-28 19:19 UTC (History)
3 users (show)

See Also:
Host:
Target:
Build:
Known to work: 10.3.0, 12.0
Known to fail: 11.2.0
Last reconfirmed: 2021-08-30 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description friedkeenan 2021-08-30 03:00:51 UTC
Minimal example: https://godbolt.org/z/P86MY1ccz

Compiles fine with clang. Compiles with gcc if you specify `Test<int>`, though the deduction guide should make them equivalent. Possibly related to Bug 93425
Comment 1 Andrew Pinski 2021-08-30 03:06:31 UTC
template<template<typename...> typename Template, typename... Args>
struct _dummy_forwarder {
    using type = Template<Args...>;
};

template<template<typename...> typename Template, typename... Args>
using dummy_forwarder = typename _dummy_forwarder<Template, Args...>::type;

template<typename T>
struct Test {
    template<typename U> using _dummy = U; 

    using Element = dummy_forwarder<_dummy, T>;

    Element _elem;

    constexpr Test(const Element elem) : _elem(elem) { }
};

template<typename T>
Test(T) -> Test<T>;

consteval void test() {
    const auto t = Test(1);
}
Comment 2 Andrew Pinski 2021-08-30 21:30:38 UTC
Confirmed.
Comment 3 Patrick Palka 2022-02-01 17:01:44 UTC
Started with r11-2748.
Comment 4 GCC Commits 2022-03-28 13:37:34 UTC
The master branch has been updated by Jason Merrill <jason@gcc.gnu.org>:

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

commit r12-7853-gb854ce130ebbfdf2f882ef08538746030513b44b
Author: Jason Merrill <jason@redhat.com>
Date:   Sat Mar 26 23:54:22 2022 -0400

    c++: CTAD and member alias template [PR102123]
    
    When building a deduction guide from the Test constructor, we need to
    rewrite the use of _dummy into a dependent reference, i.e. Test<T>::template
    _dummy.  We were using SCOPE_REF for both type and non-type templates; we
    need to use UNBOUND_CLASS_TEMPLATE for type templates.
    
            PR c++/102123
    
    gcc/cp/ChangeLog:
    
            * pt.cc (tsubst_copy): Use make_unbound_class_template for rewriting
            a type template reference.
    
    gcc/testsuite/ChangeLog:
    
            * g++.dg/cpp1z/class-deduction110.C: New test.
Comment 5 GCC Commits 2022-03-28 19:12:53 UTC
The releases/gcc-11 branch has been updated by Jason Merrill <jason@gcc.gnu.org>:

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

commit r11-9703-ge952290874d6b99946dc02e125c0fb0e9b13a1e3
Author: Jason Merrill <jason@redhat.com>
Date:   Sat Mar 26 23:54:22 2022 -0400

    c++: CTAD and member alias template [PR102123]
    
    When building a deduction guide from the Test constructor, we need to
    rewrite the use of _dummy into a dependent reference, i.e. Test<T>::template
    _dummy.  We were using SCOPE_REF for both type and non-type templates; we
    need to use UNBOUND_CLASS_TEMPLATE for type templates.
    
            PR c++/102123
    
    gcc/cp/ChangeLog:
    
            * pt.c (tsubst_copy): Use make_unbound_class_template for rewriting
            a type template reference.
    
    gcc/testsuite/ChangeLog:
    
            * g++.dg/cpp1z/class-deduction110.C: New test.
Comment 6 Jason Merrill 2022-03-28 19:19:10 UTC
Fixed.