public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/100764] New: Internal compiler error when unable to deduce template parameter value
@ 2021-05-26  8:55 egor_suvorov at mail dot ru
  2021-05-26  9:01 ` [Bug c++/100764] " egor_suvorov at mail dot ru
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: egor_suvorov at mail dot ru @ 2021-05-26  8:55 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 100764
           Summary: Internal compiler error when unable to deduce template
                    parameter value
           Product: gcc
           Version: 11.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: egor_suvorov at mail dot ru
  Target Milestone: ---

The following snippet, when compiled with `g++ -std=c++20`:

template <int N>
struct LiteralResolver {
        constexpr LiteralResolver(const char (&text)[N]) {
        }
    using type = int;
};
template <LiteralResolver Resolve>
using q_literal_type = decltype(Resolve)::type;
template <LiteralResolver Resolve>
q_literal_type<Resolve> operator""_q() {
}
int main() {
    "hello"_q;
}

yields the following error message with GCC 11.1 and GCC trunk on Godbolt
(https://godbolt.org/z/jnffoTvao):

'
Internal compiler error: Error reporting routines re-entered.
0x17802b1 warning(int, char const*, ...)
        ???:0
0x7d4077 do_auto_deduction(tree_node*, tree_node*, tree_node*, int,
auto_deduction_context, tree_node*, int)
        ???:0
0x7da762 tsubst(tree_node*, tree_node*, int, tree_node*)
        ???:0
0x178bef2 pp_format(pretty_printer*, text_info*)
        ???:0
0x178c540 pp_format_verbatim(pretty_printer*, text_info*)
        ???:0
0x178c621 pp_verbatim(pretty_printer*, char const*, ...)
        ???:0
0x177f6ed diagnostic_report_diagnostic(diagnostic_context*, diagnostic_info*)
        ???:0
0x17819df warning_at(rich_location*, int, char const*, ...)
        ???:0
0x6f969d finish_function(bool)
        ???:0
0x7dcec3 instantiate_decl(tree_node*, bool, bool)
        ???:0
0x7f7aab instantiate_pending_templates(int)
        ???:0
0x708f4d c_parse_final_cleanups()
        ???:0
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See <https://gcc.gnu.org/bugs/> for instructions.

My GCC 10.2.0 correctly reports an error like this:

a.cpp:10:23: error: class template argument deduction failed:
   10 | q_literal_type<Resolve> operator""_q() {
      |                       ^
a.cpp:10:23: error: no matching function for call to
'LiteralResolver(LiteralResolver<...auto...>)'
a.cpp:3:12: note: candidate: 'template<int N> LiteralResolver(const char
(&)[N])-> LiteralResolver<N>'
    3 |  constexpr LiteralResolver(const char (&text)[N]) {
      |            ^~~~~~~~~~~~~~~
a.cpp:3:12: note:   template argument deduction/substitution failed:
a.cpp:10:23: note:   mismatched types 'const char [N]' and
'LiteralResolver<...auto...>'
   10 | q_literal_type<Resolve> operator""_q() {
      |                       ^
a.cpp:2:8: note: candidate: 'template<int N>
LiteralResolver(LiteralResolver<N>)-> LiteralResolver<N>'
    2 | struct LiteralResolver {
      |        ^~~~~~~~~~~~~~~
a.cpp:2:8: note:   template argument deduction/substitution failed:
a.cpp:10:23: note:   mismatched types 'LiteralResolver<N>' and
'LiteralResolver<...auto...>'
   10 | q_literal_type<Resolve> operator""_q() {
      |                       ^
a.cpp: In function 'int operator""_q()':
a.cpp:11:1: warning: no return statement in function returning non-void
[-Wreturn-type]
   11 | }
      | ^

Looks like a regression. Unfortunately, I don't have the exact build
information for Godbolt's GCC.

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

end of thread, other threads:[~2023-05-22 14:53 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-26  8:55 [Bug c++/100764] New: Internal compiler error when unable to deduce template parameter value egor_suvorov at mail dot ru
2021-05-26  9:01 ` [Bug c++/100764] " egor_suvorov at mail dot ru
2021-05-26  9:58 ` marxin at gcc dot gnu.org
2021-08-10  3:14 ` pinskia at gcc dot gnu.org
2023-05-22 14:52 ` ppalka at gcc dot gnu.org
2023-05-22 14:53 ` 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).