public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/93085] ICE in get_class_binding_direct and alias_ctad_tweaks, with C++20 NTTP + CTAD + alias template
       [not found] <bug-93085-4@http.gcc.gnu.org/bugzilla/>
@ 2020-10-17 23:57 ` johelegp at gmail dot com
  2020-10-18  0:11 ` arthur.j.odwyer at gmail dot com
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 6+ messages in thread
From: johelegp at gmail dot com @ 2020-10-17 23:57 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93085

Johel Ernesto Guerrero Peña <johelegp at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |johelegp at gmail dot com

--- Comment #2 from Johel Ernesto Guerrero Peña <johelegp at gmail dot com> ---
Invalid because it passes (a) type template argument(s) to a template template
parameter.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug c++/93085] ICE in get_class_binding_direct and alias_ctad_tweaks, with C++20 NTTP + CTAD + alias template
       [not found] <bug-93085-4@http.gcc.gnu.org/bugzilla/>
  2020-10-17 23:57 ` [Bug c++/93085] ICE in get_class_binding_direct and alias_ctad_tweaks, with C++20 NTTP + CTAD + alias template johelegp at gmail dot com
@ 2020-10-18  0:11 ` arthur.j.odwyer at gmail dot com
  2020-10-18  0:46 ` johelegp at gmail dot com
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 6+ messages in thread
From: arthur.j.odwyer at gmail dot com @ 2020-10-18  0:11 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93085

--- Comment #3 from Arthur O'Dwyer <arthur.j.odwyer at gmail dot com> ---
Re comment 2: My original test code was "invalid-code", but here's one I
believe to be "valid-code" in C++20.

// https://godbolt.org/z/dqcWeq
template<template<class> class A>
struct G {
    template<class T> using B = A<T>;
    template<B> static int foo();
    template<int> static int foo();
    int x = foo<42>();  // OK
};

test.cc:7:21: internal compiler error: in get_class_binding_direct, at
cp/name-lookup.c:1238
    7 |     int x = foo<42>();  // OK
      |                     ^

====
If you change the `<B>` to an `<A>`, the ICE disappears, but GCC still gives a
bogus error at template-definition time:

// https://godbolt.org/z/Tjrnzv
template<template<class> class A>
struct G {
    template<class T> using B = A<T>;
    template<A> static int foo();    // #1
    template<int> static int foo();  // #2
    int x = foo<42>();  // OK
};

test.cc:7:21: error: call of overloaded 'foo()' is ambiguous
    7 |     int x = foo<42>();  // OK
      |                     ^

GCC shouldn't even be trying to resolve `foo<42>()` until `G` has been
instantiated; and once `G` has been instantiated with some specific `A`, this
call may or may not be ambiguous (depending on whether it's possible to deduce
the template arguments to foo #1 or not).

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug c++/93085] ICE in get_class_binding_direct and alias_ctad_tweaks, with C++20 NTTP + CTAD + alias template
       [not found] <bug-93085-4@http.gcc.gnu.org/bugzilla/>
  2020-10-17 23:57 ` [Bug c++/93085] ICE in get_class_binding_direct and alias_ctad_tweaks, with C++20 NTTP + CTAD + alias template johelegp at gmail dot com
  2020-10-18  0:11 ` arthur.j.odwyer at gmail dot com
@ 2020-10-18  0:46 ` johelegp at gmail dot com
  2021-04-10  6:14 ` jason at gcc dot gnu.org
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 6+ messages in thread
From: johelegp at gmail dot com @ 2020-10-18  0:46 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93085

--- Comment #4 from Johel Ernesto Guerrero Peña <johelegp at gmail dot com> ---
> GCC shouldn't even be trying to resolve `foo<42>()` until `G` has been instantiated.

That's right. I came across this bug report when reporting such an issue:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97476.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug c++/93085] ICE in get_class_binding_direct and alias_ctad_tweaks, with C++20 NTTP + CTAD + alias template
       [not found] <bug-93085-4@http.gcc.gnu.org/bugzilla/>
                   ` (2 preceding siblings ...)
  2020-10-18  0:46 ` johelegp at gmail dot com
@ 2021-04-10  6:14 ` jason at gcc dot gnu.org
  2021-04-12 21:30 ` cvs-commit at gcc dot gnu.org
  2021-04-14 18:59 ` cvs-commit at gcc dot gnu.org
  5 siblings, 0 replies; 6+ messages in thread
From: jason at gcc dot gnu.org @ 2021-04-10  6:14 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93085

Jason Merrill <jason at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Assignee|unassigned at gcc dot gnu.org      |jason at gcc dot gnu.org
             Status|WAITING                     |ASSIGNED
                 CC|                            |jason at gcc dot gnu.org

--- Comment #5 from Jason Merrill <jason at gcc dot gnu.org> ---
The ICEs are fixed, I want to address the second testcase in comment #3.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug c++/93085] ICE in get_class_binding_direct and alias_ctad_tweaks, with C++20 NTTP + CTAD + alias template
       [not found] <bug-93085-4@http.gcc.gnu.org/bugzilla/>
                   ` (3 preceding siblings ...)
  2021-04-10  6:14 ` jason at gcc dot gnu.org
@ 2021-04-12 21:30 ` cvs-commit at gcc dot gnu.org
  2021-04-14 18:59 ` cvs-commit at gcc dot gnu.org
  5 siblings, 0 replies; 6+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-04-12 21:30 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93085

--- Comment #6 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Jason Merrill <jason@gcc.gnu.org>:

https://gcc.gnu.org/g:84081e2c6bd43a6790f751755865cf4227adac7c

commit r11-8137-g84081e2c6bd43a6790f751755865cf4227adac7c
Author: Jason Merrill <jason@redhat.com>
Date:   Sat Apr 10 02:10:32 2021 -0400

    c++: premature overload resolution [PR93085]

    We can't resolve the call to foo<42> before instantiation of G, because the
    template parameter of #1 has dependent type.  But we were missing that in
    our dependency check, because the tree walk of DECL_TEMPLATE_PARMS doesn't
    look into the types of template parameters.  So look at them directly.

    gcc/cp/ChangeLog:

            PR c++/93085
            * pt.c (uses_outer_template_parms): Handle non-type and template
            template parameters specifically.

    gcc/testsuite/ChangeLog:

            PR c++/93085
            * g++.dg/template/dependent-tmpl1.C: New test.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug c++/93085] ICE in get_class_binding_direct and alias_ctad_tweaks, with C++20 NTTP + CTAD + alias template
       [not found] <bug-93085-4@http.gcc.gnu.org/bugzilla/>
                   ` (4 preceding siblings ...)
  2021-04-12 21:30 ` cvs-commit at gcc dot gnu.org
@ 2021-04-14 18:59 ` cvs-commit at gcc dot gnu.org
  5 siblings, 0 replies; 6+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-04-14 18:59 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93085

--- Comment #7 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Jason Merrill <jason@gcc.gnu.org>:

https://gcc.gnu.org/g:00a2774923c1dc5666cd26bb9b8c37b1b7dd689d

commit r11-8182-g00a2774923c1dc5666cd26bb9b8c37b1b7dd689d
Author: Jason Merrill <jason@redhat.com>
Date:   Wed Apr 14 14:14:31 2021 -0400

    c++: premature overload resolution redux [PR100078]

    My patch for PR93085 didn't consider that a default template argument can
    also make a template dependent.

    gcc/cp/ChangeLog:

            PR c++/100078
            PR c++/93085
            * pt.c (uses_outer_template_parms): Also look at default
            template argument.

    gcc/testsuite/ChangeLog:

            PR c++/100078
            * g++.dg/template/dependent-tmpl2.C: New test.

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2021-04-14 18:59 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <bug-93085-4@http.gcc.gnu.org/bugzilla/>
2020-10-17 23:57 ` [Bug c++/93085] ICE in get_class_binding_direct and alias_ctad_tweaks, with C++20 NTTP + CTAD + alias template johelegp at gmail dot com
2020-10-18  0:11 ` arthur.j.odwyer at gmail dot com
2020-10-18  0:46 ` johelegp at gmail dot com
2021-04-10  6:14 ` jason at gcc dot gnu.org
2021-04-12 21:30 ` cvs-commit at gcc dot gnu.org
2021-04-14 18:59 ` cvs-commit at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).