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

* [Bug c++/100764] Internal compiler error when unable to deduce template parameter value
  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 ` egor_suvorov at mail dot ru
  2021-05-26  9:58 ` marxin at gcc dot gnu.org
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: egor_suvorov at mail dot ru @ 2021-05-26  9:01 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from Egor Suvorov <egor_suvorov at mail dot ru> ---
UPD: compiling with `g++ -v -std=c++20` on Godbolt's GCC 11.1 yields the
following information about versions:

Using built-in specs.
COLLECT_GCC=/opt/compiler-explorer/gcc-11.1.0/bin/g++
Target: x86_64-linux-gnu
Configured with: ../gcc-11.1.0/configure
--prefix=/opt/compiler-explorer/gcc-build/staging --build=x86_64-linux-gnu
--host=x86_64-linux-gnu --target=x86_64-linux-gnu --disable-bootstrap
--enable-multiarch --with-abi=m64 --with-multilib-list=m32,m64,mx32
--enable-multilib --enable-clocale=gnu
--enable-languages=c,c++,fortran,ada,go,d --enable-ld=yes --enable-gold=yes
--enable-libstdcxx-debug --enable-libstdcxx-time=yes --enable-linker-build-id
--enable-lto --enable-plugins --enable-threads=posix
--with-pkgversion=Compiler-Explorer-Build
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 11.1.0 (Compiler-Explorer-Build) 
COLLECT_GCC_OPTIONS='-fdiagnostics-color=always' '-g' '-o' '/app/output.s'
'-masm=intel' '-S' '-std=c++20' '-v' '-shared-libgcc' '-mtune=generic'
'-march=x86-64' '-dumpdir' '/app/'

/opt/compiler-explorer/gcc-11.1.0/bin/../libexec/gcc/x86_64-linux-gnu/11.1.0/cc1plus
-quiet -v -imultiarch x86_64-linux-gnu -iprefix
/opt/compiler-explorer/gcc-11.1.0/bin/../lib/gcc/x86_64-linux-gnu/11.1.0/
-D_GNU_SOURCE <source> -quiet -dumpdir /app/ -dumpbase output.cpp -dumpbase-ext
.cpp -masm=intel -mtune=generic -march=x86-64 -g -std=c++20 -version
-fdiagnostics-color=always -o /app/output.s
GNU C++20 (Compiler-Explorer-Build) version 11.1.0 (x86_64-linux-gnu)
        compiled by GNU C version 7.5.0, GMP version 6.1.0, MPFR version 3.1.4,
MPC version 1.0.3, isl version isl-0.18-GMP

GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
ignoring nonexistent directory
"/opt/compiler-explorer/gcc-11.1.0/bin/../lib/gcc/x86_64-linux-gnu/11.1.0/../../../../x86_64-linux-gnu/include"
ignoring duplicate directory
"/opt/compiler-explorer/gcc-11.1.0/bin/../lib/gcc/../../lib/gcc/x86_64-linux-gnu/11.1.0/../../../../include/c++/11.1.0"
ignoring duplicate directory
"/opt/compiler-explorer/gcc-11.1.0/bin/../lib/gcc/../../lib/gcc/x86_64-linux-gnu/11.1.0/../../../../include/c++/11.1.0/x86_64-linux-gnu"
ignoring duplicate directory
"/opt/compiler-explorer/gcc-11.1.0/bin/../lib/gcc/../../lib/gcc/x86_64-linux-gnu/11.1.0/../../../../include/c++/11.1.0/backward"
ignoring duplicate directory
"/opt/compiler-explorer/gcc-11.1.0/bin/../lib/gcc/../../lib/gcc/x86_64-linux-gnu/11.1.0/include"
ignoring nonexistent directory "/usr/local/include/x86_64-linux-gnu"
ignoring duplicate directory
"/opt/compiler-explorer/gcc-11.1.0/bin/../lib/gcc/../../lib/gcc/x86_64-linux-gnu/11.1.0/include-fixed"
ignoring nonexistent directory
"/opt/compiler-explorer/gcc-11.1.0/bin/../lib/gcc/../../lib/gcc/x86_64-linux-gnu/11.1.0/../../../../x86_64-linux-gnu/include"
#include "..." search starts here:
#include <...> search starts here:

/opt/compiler-explorer/gcc-11.1.0/bin/../lib/gcc/x86_64-linux-gnu/11.1.0/../../../../include/c++/11.1.0

/opt/compiler-explorer/gcc-11.1.0/bin/../lib/gcc/x86_64-linux-gnu/11.1.0/../../../../include/c++/11.1.0/x86_64-linux-gnu

/opt/compiler-explorer/gcc-11.1.0/bin/../lib/gcc/x86_64-linux-gnu/11.1.0/../../../../include/c++/11.1.0/backward

/opt/compiler-explorer/gcc-11.1.0/bin/../lib/gcc/x86_64-linux-gnu/11.1.0/include

/opt/compiler-explorer/gcc-11.1.0/bin/../lib/gcc/x86_64-linux-gnu/11.1.0/include-fixed
 /usr/local/include
 /opt/compiler-explorer/gcc-11.1.0/bin/../lib/gcc/../../include
 /usr/include/x86_64-linux-gnu
 /usr/include
End of search list.
GNU C++20 (Compiler-Explorer-Build) version 11.1.0 (x86_64-linux-gnu)
        compiled by GNU C version 7.5.0, GMP version 6.1.0, MPFR version 3.1.4,
MPC version 1.0.3, isl version isl-0.18-GMP

GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
Compiler executable checksum: 9cf7a593a02f6cca3d19cdf19881522c
'
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.

Same flags with Godbolt's GCC trunk yield the following:

Using built-in specs.
COLLECT_GCC=/opt/compiler-explorer/gcc-snapshot/bin/g++
Target: x86_64-linux-gnu
Configured with: ../gcc-trunk-20210524/configure
--prefix=/opt/compiler-explorer/gcc-build/staging --build=x86_64-linux-gnu
--host=x86_64-linux-gnu --target=x86_64-linux-gnu --disable-bootstrap
--enable-multiarch --with-abi=m64 --with-multilib-list=m32,m64,mx32
--enable-multilib --enable-clocale=gnu --enable-languages=c,c++,fortran,ada,d
--enable-ld=yes --enable-gold=yes --enable-libstdcxx-debug
--enable-libstdcxx-time=yes --enable-linker-build-id --enable-lto
--enable-plugins --enable-threads=posix
--with-pkgversion=Compiler-Explorer-Build
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 12.0.0 20210523 (experimental) (Compiler-Explorer-Build) 
COLLECT_GCC_OPTIONS='-fdiagnostics-color=always' '-g' '-o' '/app/output.s'
'-masm=intel' '-S' '-std=c++20' '-v' '-shared-libgcc' '-mtune=generic'
'-march=x86-64' '-dumpdir' '/app/'

/opt/compiler-explorer/gcc-trunk-20210524/bin/../libexec/gcc/x86_64-linux-gnu/12.0.0/cc1plus
-quiet -v -imultiarch x86_64-linux-gnu -iprefix
/opt/compiler-explorer/gcc-trunk-20210524/bin/../lib/gcc/x86_64-linux-gnu/12.0.0/
-D_GNU_SOURCE <source> -quiet -dumpdir /app/ -dumpbase output.cpp -dumpbase-ext
.cpp -masm=intel -mtune=generic -march=x86-64 -g -std=c++20 -version
-fdiagnostics-color=always -o /app/output.s
GNU C++20 (Compiler-Explorer-Build) version 12.0.0 20210523 (experimental)
(x86_64-linux-gnu)
        compiled by GNU C version 7.5.0, GMP version 6.1.0, MPFR version 3.1.6,
MPC version 1.0.3, isl version isl-0.18-GMP

GGC heuristics: --param ggc-min-expand=30 --param ggc-min-heapsize=4096
ignoring nonexistent directory
"/opt/compiler-explorer/gcc-trunk-20210524/bin/../lib/gcc/x86_64-linux-gnu/12.0.0/../../../../x86_64-linux-gnu/include"
ignoring duplicate directory
"/opt/compiler-explorer/gcc-trunk-20210524/bin/../lib/gcc/../../lib/gcc/x86_64-linux-gnu/12.0.0/../../../../include/c++/12.0.0"
ignoring duplicate directory
"/opt/compiler-explorer/gcc-trunk-20210524/bin/../lib/gcc/../../lib/gcc/x86_64-linux-gnu/12.0.0/../../../../include/c++/12.0.0/x86_64-linux-gnu"
ignoring duplicate directory
"/opt/compiler-explorer/gcc-trunk-20210524/bin/../lib/gcc/../../lib/gcc/x86_64-linux-gnu/12.0.0/../../../../include/c++/12.0.0/backward"
ignoring duplicate directory
"/opt/compiler-explorer/gcc-trunk-20210524/bin/../lib/gcc/../../lib/gcc/x86_64-linux-gnu/12.0.0/include"
ignoring nonexistent directory "/usr/local/include/x86_64-linux-gnu"
ignoring duplicate directory
"/opt/compiler-explorer/gcc-trunk-20210524/bin/../lib/gcc/../../lib/gcc/x86_64-linux-gnu/12.0.0/include-fixed"
ignoring nonexistent directory
"/opt/compiler-explorer/gcc-trunk-20210524/bin/../lib/gcc/../../lib/gcc/x86_64-linux-gnu/12.0.0/../../../../x86_64-linux-gnu/include"
#include "..." search starts here:
#include <...> search starts here:

/opt/compiler-explorer/gcc-trunk-20210524/bin/../lib/gcc/x86_64-linux-gnu/12.0.0/../../../../include/c++/12.0.0

/opt/compiler-explorer/gcc-trunk-20210524/bin/../lib/gcc/x86_64-linux-gnu/12.0.0/../../../../include/c++/12.0.0/x86_64-linux-gnu

/opt/compiler-explorer/gcc-trunk-20210524/bin/../lib/gcc/x86_64-linux-gnu/12.0.0/../../../../include/c++/12.0.0/backward

/opt/compiler-explorer/gcc-trunk-20210524/bin/../lib/gcc/x86_64-linux-gnu/12.0.0/include

/opt/compiler-explorer/gcc-trunk-20210524/bin/../lib/gcc/x86_64-linux-gnu/12.0.0/include-fixed
 /usr/local/include
 /opt/compiler-explorer/gcc-trunk-20210524/bin/../lib/gcc/../../include
 /usr/include/x86_64-linux-gnu
 /usr/include
End of search list.
GNU C++20 (Compiler-Explorer-Build) version 12.0.0 20210523 (experimental)
(x86_64-linux-gnu)
        compiled by GNU C version 7.5.0, GMP version 6.1.0, MPFR version 3.1.6,
MPC version 1.0.3, isl version isl-0.18-GMP

GGC heuristics: --param ggc-min-expand=30 --param ggc-min-heapsize=4096
Compiler executable checksum: 9890cddb62c438d33e2289d3df93d52e
'
Internal compiler error: Error reporting routines re-entered.
0x1d24e71 warning(int, char const*, ...)
        ???:0
0x910a43 do_auto_deduction(tree_node*, tree_node*, tree_node*, int,
auto_deduction_context, tree_node*, int)
        ???:0
0x91e03b tsubst(tree_node*, tree_node*, int, tree_node*)
        ???:0
0x1d41691 pp_format(pretty_printer*, text_info*)
        ???:0
0x1d41d10 pp_format_verbatim(pretty_printer*, text_info*)
        ???:0
0x1d41df1 pp_verbatim(pretty_printer*, char const*, ...)
        ???:0
0x1d24346 diagnostic_report_diagnostic(diagnostic_context*, diagnostic_info*)
        ???:0
0x1d26d0f warning_at(rich_location*, int, char const*, ...)
        ???:0
0x7b5b5b finish_function(bool)
        ???:0
0x923d3f instantiate_decl(tree_node*, bool, bool)
        ???:0
0x965e0b instantiate_pending_templates(int)
        ???:0
0x7d2449 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.

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

* [Bug c++/100764] Internal compiler error when unable to deduce template parameter value
  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
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: marxin at gcc dot gnu.org @ 2021-05-26  9:58 UTC (permalink / raw)
  To: gcc-bugs

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

Martin Liška <marxin at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jason at gcc dot gnu.org,
                   |                            |marxin at gcc dot gnu.org

--- Comment #2 from Martin Liška <marxin at gcc dot gnu.org> ---
It seems GCC 10.3.0 accepts the code since
g:e6e42891d80c12c4fac36d6273b8d4e31a3d0a2a, master ICEs since
r11-5752-ga95753214b55d21e

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

* [Bug c++/100764] Internal compiler error when unable to deduce template parameter value
  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
  4 siblings, 0 replies; 6+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-08-10  3:14 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
     Ever confirmed|0                           |1
   Last reconfirmed|                            |2021-08-10

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

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

* [Bug c++/100764] Internal compiler error when unable to deduce template parameter value
  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
                   ` (2 preceding siblings ...)
  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
  4 siblings, 0 replies; 6+ messages in thread
From: ppalka at gcc dot gnu.org @ 2023-05-22 14:52 UTC (permalink / raw)
  To: gcc-bugs

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

Patrick Palka <ppalka at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           See Also|                            |https://gcc.gnu.org/bugzill
                   |                            |a/show_bug.cgi?id=105143,
                   |                            |https://gcc.gnu.org/bugzill
                   |                            |a/show_bug.cgi?id=93083
           Keywords|ice-on-invalid-code         |ice-on-valid-code
             Status|NEW                         |RESOLVED
                 CC|                            |ppalka at gcc dot gnu.org
   Target Milestone|---                         |11.3
         Resolution|---                         |FIXED

--- Comment #4 from Patrick Palka <ppalka at gcc dot gnu.org> ---
Looks like this is fixed for GCC 11.3+ by the fix for PR105143 (and PR93083). 
A new testcase seems unnecessary since the existing tests from these PRs ought
to sufficiently cover this situation.

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

* [Bug c++/100764] Internal compiler error when unable to deduce template parameter value
  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
                   ` (3 preceding siblings ...)
  2023-05-22 14:52 ` ppalka at gcc dot gnu.org
@ 2023-05-22 14:53 ` ppalka at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: ppalka at gcc dot gnu.org @ 2023-05-22 14:53 UTC (permalink / raw)
  To: gcc-bugs

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

Patrick Palka <ppalka at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|11.3                        |10.3

--- Comment #5 from Patrick Palka <ppalka at gcc dot gnu.org> ---
Even 10.3 accepts it as Martin pointed out.

^ 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).