public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/103672] New: using with template<template<class...> class> causes internal compiler error
@ 2021-12-12 18:51 turtlefight at ymail dot com
  2021-12-13 11:59 ` [Bug c++/103672] [10/11/12 Regression] " redi at gcc dot gnu.org
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: turtlefight at ymail dot com @ 2021-12-12 18:51 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 103672
           Summary: using with template<template<class...> class> causes
                    internal compiler error
           Product: gcc
           Version: 11.2.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: turtlefight at ymail dot com
  Target Milestone: ---

The following example results in an internal compiler error.
It does compile fine with clang and msvc.

Example Code:

#include <functional>
#include <memory>

template<class T>
struct unique {
    auto operator()(auto&&... args) {
        return std::make_unique<T>(std::forward<decltype(args)>(args)...);
    }
};

template<template<class...> class T, class... Args>
using deduced_type = decltype(T{std::declval<Args>()...});

template<template<class> class F, template<class...> class T, class... Args>
auto make(Args&&... args) {
    return F<deduced_type<T, Args...>>{}(std::forward<Args>(args)...);
}

template<class A, class B>
struct Foo { Foo(A,B) {} };


int main(){
    auto foo_unique = make<unique, Foo>(1, 2);
}


Full Error Message:
<source>: In instantiation of 'auto make(Args&& ...) [with F = unique; T = Foo;
Args = {int, int}]':
<source>:24:40:   required from here
<source>:16:41: internal compiler error: in tsubst, at cp/pt.c:15632
   16 |     return F<deduced_type<T, Args...>>{}(std::forward<Args>(args)...);
      |            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
0x21004e9 internal_error(char const*, ...)
        ???:0
0x7e96eb fancy_abort(char const*, int, char const*)
        ???:0
0xa5fde7 tsubst(tree_node*, tree_node*, int, tree_node*)
        ???:0
0xa5d3af tsubst(tree_node*, tree_node*, int, tree_node*)
        ???:0
0xa89b76 tsubst_template_args(tree_node*, tree_node*, int, tree_node*)
        ???:0
0xa5d954 tsubst(tree_node*, tree_node*, int, tree_node*)
        ???:0
0xa5eb8d tsubst(tree_node*, tree_node*, int, tree_node*)
        ???:0
0xa63a47 instantiate_decl(tree_node*, bool, bool)
        ???:0
0x904ebe maybe_instantiate_decl(tree_node*)
        ???:0
0x906980 mark_used(tree_node*, int)
        ???:0
0x819197 build_new_function_call(tree_node*, vec<tree_node*, va_gc,
vl_embed>**, int)
        ???:0
0xaca89c finish_call_expr(tree_node*, vec<tree_node*, va_gc, vl_embed>**, bool,
bool, int)
        ???:0
0xa29b8d c_parse_file()
        ???:0
0xbb6bb2 c_common_parse_file()
        ???:0


Godbolt Example: https://godbolt.org/z/rd4PdYrq8


What's interesting is that the code compiles without problems if a using
declaration is not used, e.g.:

template<template<class> class F, template<class...> class T, class... Args>
auto make(Args&&... args) {
    return
F<decltype(T{std::declval<Args>()...})>{}(std::forward<Args>(args)...);
}


Godbolt Example: https://godbolt.org/z/Pd3Mjs8rG

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

end of thread, other threads:[~2023-05-21 15:12 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-12 18:51 [Bug c++/103672] New: using with template<template<class...> class> causes internal compiler error turtlefight at ymail dot com
2021-12-13 11:59 ` [Bug c++/103672] [10/11/12 Regression] " redi at gcc dot gnu.org
2022-01-04  9:47 ` rguenth at gcc dot gnu.org
2022-01-13 15:28 ` ppalka at gcc dot gnu.org
2022-01-20 14:26 ` cvs-commit at gcc dot gnu.org
2022-01-20 14:30 ` [Bug c++/103672] [10/11 " ppalka at gcc dot gnu.org
2022-05-11 17:48 ` ppalka at gcc dot gnu.org
2022-06-28 10:47 ` jakub at gcc dot gnu.org
2023-05-21 15:12 ` ppalka 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).