public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/113649] New: ICE: nested template class template argument deduction
@ 2024-01-29  7:57 schaumb at gmail dot com
  2024-01-29  8:10 ` [Bug c++/113649] " pinskia at gcc dot gnu.org
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: schaumb at gmail dot com @ 2024-01-29  7:57 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 113649
           Summary: ICE: nested template class template argument deduction
           Product: gcc
           Version: 14.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: schaumb at gmail dot com
  Target Milestone: ---

The following code does not compile, see here https://godbolt.org/z/vz5KMzhsh:


template<class ...Ts>
struct params {
    template <typename Return>
    struct return_type {
        constexpr return_type(Return (*p1)(Ts...)){}
    };

    template <typename Return>
    return_type(Return (*)(Ts...)) -> 
    return_type<Return>;


    template<return_type Any>
    struct addr {};
};

void x(double);

template struct params<double>::addr<&x>;


It runs to internal compiler error:

<source>:19:40: internal compiler error: in build_function_type, at
tree.cc:7488
   19 | template struct params<double>::addr<&x>;
      |                                        ^
0x2647edc internal_error(char const*, ...)
        ???:0
0xa51cb7 fancy_abort(char const*, int, char const*)
        ???:0
0xc72375 do_auto_deduction(tree_node*, tree_node*, tree_node*, int,
auto_deduction_context, tree_node*, int, tree_node*)
        ???:0
0xc76223 coerce_template_parms(tree_node*, tree_node*, tree_node*, int, bool)
        ???:0
0xc93089 lookup_template_class(tree_node*, tree_node*, tree_node*, tree_node*,
int, int)
        ???:0
0xccf8ff finish_template_type(tree_node*, tree_node*, int)
        ???:0
0xc53d2a c_parse_file()
        ???:0
0xda79a9 c_common_parse_file()
        ???:0
Please submit a full bug report, with preprocessed source (by using
-freport-bug).
Please include the complete backtrace with any bug report.
See <https://gcc.gnu.org/bugs/> for instructions.
Compiler returned: 1

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

* [Bug c++/113649] ICE: nested template class template argument deduction
  2024-01-29  7:57 [Bug c++/113649] New: ICE: nested template class template argument deduction schaumb at gmail dot com
@ 2024-01-29  8:10 ` pinskia at gcc dot gnu.org
  2024-01-29  9:00 ` pinskia at gcc dot gnu.org
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: pinskia at gcc dot gnu.org @ 2024-01-29  8:10 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2024-01-29
           Keywords|                            |ice-on-valid-code
     Ever confirmed|0                           |1

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Confirmed.

Related (not ICEing but still incorrectly to reject) testcase:
```
template<int>
struct params {
    template <typename Return>
    struct return_type {
        constexpr return_type(Return (*p1)()){}
    };

    template <typename Return>
    return_type(Return (*)()) -> 
    return_type<Return>;


    template<return_type Any>
    struct addr {};
};

void x();

template struct params<1>::addr<&x>;
```

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

* [Bug c++/113649] ICE: nested template class template argument deduction
  2024-01-29  7:57 [Bug c++/113649] New: ICE: nested template class template argument deduction schaumb at gmail dot com
  2024-01-29  8:10 ` [Bug c++/113649] " pinskia at gcc dot gnu.org
@ 2024-01-29  9:00 ` pinskia at gcc dot gnu.org
  2024-01-30 16:51 ` mpolacek at gcc dot gnu.org
  2024-02-08 14:11 ` cvs-commit at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: pinskia at gcc dot gnu.org @ 2024-01-29  9:00 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
      Known to fail|                            |12.3.0

--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
This was rejected before GCC 12.3.0 with an error message about the deduction
guide not being at the namespace level.

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

* [Bug c++/113649] ICE: nested template class template argument deduction
  2024-01-29  7:57 [Bug c++/113649] New: ICE: nested template class template argument deduction schaumb at gmail dot com
  2024-01-29  8:10 ` [Bug c++/113649] " pinskia at gcc dot gnu.org
  2024-01-29  9:00 ` pinskia at gcc dot gnu.org
@ 2024-01-30 16:51 ` mpolacek at gcc dot gnu.org
  2024-02-08 14:11 ` cvs-commit at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2024-01-30 16:51 UTC (permalink / raw)
  To: gcc-bugs

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

Marek Polacek <mpolacek at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |mpolacek at gcc dot gnu.org,
                   |                            |ppalka at gcc dot gnu.org

--- Comment #3 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
Seems the ICE started with r13-4876-gbd1fc4a219d8c0:

commit bd1fc4a219d8c0fad0ec41002e895b49e384c1c2
Author: Patrick Palka <ppalka@redhat.com>
Date:   Fri Dec 23 09:18:37 2022 -0500

    c++: template friend with variadic constraints [PR107853]

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

* [Bug c++/113649] ICE: nested template class template argument deduction
  2024-01-29  7:57 [Bug c++/113649] New: ICE: nested template class template argument deduction schaumb at gmail dot com
                   ` (2 preceding siblings ...)
  2024-01-30 16:51 ` mpolacek at gcc dot gnu.org
@ 2024-02-08 14:11 ` cvs-commit at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2024-02-08 14:11 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Patrick Palka <ppalka@gcc.gnu.org>:

https://gcc.gnu.org/g:465b9c51f5c79ce3fbb36f1abc7194b39ad9cae7

commit r14-8886-g465b9c51f5c79ce3fbb36f1abc7194b39ad9cae7
Author: Patrick Palka <ppalka@redhat.com>
Date:   Thu Feb 8 09:10:44 2024 -0500

    c++: NTTP type CTAD w/ tmpl from current inst [PR113649]

    Since template argument coercion happens relative to the most general
    template (for a class template at least), during NTTP type CTAD we might
    need to consider outer arguments particularly if the CTAD template is from
    the current instantiation (and so depends on outer template parameters).

    This patch makes do_class_deduction substitute as many levels of outer
    template arguments into a CTAD template (from the current instantiation)
    as it can take.

            PR c++/113649

    gcc/cp/ChangeLog:

            * pt.cc (do_class_deduction): Add outer_targs parameter.
            Substitute outer arguments into the CTAD template.
            (do_auto_deduction): Pass outer_targs to do_class_deduction.

    gcc/testsuite/ChangeLog:

            * g++.dg/cpp2a/nontype-class65.C: New test.

    Reviewed-by: Jason Merrill <jason@redhat.com>

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

end of thread, other threads:[~2024-02-08 14:11 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-01-29  7:57 [Bug c++/113649] New: ICE: nested template class template argument deduction schaumb at gmail dot com
2024-01-29  8:10 ` [Bug c++/113649] " pinskia at gcc dot gnu.org
2024-01-29  9:00 ` pinskia at gcc dot gnu.org
2024-01-30 16:51 ` mpolacek at gcc dot gnu.org
2024-02-08 14:11 ` 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).