Package: gcc-12
Version: 12.3.0-10
Severity: normal
X-Debbugs-Cc: andre.nauj...@keysight.com

Hello.

The following piece of code generates a compiler error with gcc-12 in C++20
mode:

template <typename T, float D>
struct F {
        static double foo() { return D; }
};

template <typename T>
struct F<T, 1.0f> {
        static double foo() { return 1.0; }
};

int main()
{
        return F<void, 1.0f>::foo();
}

gcc-13 in sid does compile this correctly. on godbolt only gcc-trunk, not
gcc-13, compiles this, so from my point of view, it may be a Debian patch in
gcc-13 in sid, which fixes this.

The error (on gcc-12 from sid) is this:

$ g++-12 -std=c++20 -o test test.cpp
test.cpp: In function ‘int main()’:
test.cpp:13:29: internal compiler error: in unify, at cp/pt.cc:24903
   13 |         return F<void, 1.0f>::foo();
      |                             ^~
0x7f41729256c9 __libc_start_call_main
        ../sysdeps/nptl/libc_start_call_main.h:58
0x7f4172925784 __libc_start_main_impl
        ../csu/libc-start.c:360
Please submit a full bug report, with preprocessed source (by using -freport-
bug).
Please include the complete backtrace with any bug report.
See <file:///usr/share/doc/gcc-12/README.Bugs> for instructions.



gcc in bookworm looks a little different but should be the same bug:

$ g++ -std=c++20 -o test test.cpp
test.cpp: In function 'int main()':
test.cpp:13:29: internal compiler error: in unify, at cp/pt.cc:24832
   13 |         return F<void, 1.0f>::foo();
      |                             ^~
0x1afaeb6 internal_error(char const*, ...)
        ???:0
0x69ec5a fancy_abort(char const*, int, char const*)
        ???:0
0x813491 most_specialized_partial_spec(tree_node*, int)
        ???:0
0x830231 instantiate_class_template(tree_node*)
        ???:0
0x86621b complete_type(tree_node*)
        ???:0
0x7f5c79 c_parse_file()
        ???:0
0x8e019d 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 <file:///usr/share/doc/gcc-12/README.Bugs> for instructions.

Thanks in advance!

Andre



-- System Information:
Debian Release: trixie/sid
  APT prefers unstable-debug
  APT policy: (500, 'unstable-debug'), (500, 'unstable')
Architecture: amd64 (x86_64)

Kernel: Linux 6.5.0-2-amd64 (SMP w/16 CPU threads; PREEMPT)
Locale: LANG=C.UTF-8, LC_CTYPE=C.UTF-8 (charmap=UTF-8), LANGUAGE not set
Shell: /bin/sh linked to /usr/bin/dash
Init: systemd (via /run/systemd/system)
LSM: AppArmor: enabled

Versions of packages gcc-12 depends on:
ii  binutils       2.41-6
ii  cpp-12         12.3.0-10
ii  gcc-12-base    12.3.0-10
ii  libc6          2.37-12
ii  libcc1-0       13.2.0-5
ii  libgcc-12-dev  12.3.0-10
ii  libgcc-s1      13.2.0-5
ii  libgmp10       2:6.3.0+dfsg-2
ii  libisl23       0.26-3
ii  libmpc3        1.3.1-1
ii  libmpfr6       4.2.1-1
ii  libstdc++6     13.2.0-5
ii  libzstd1       1.5.5+dfsg2-2
ii  zlib1g         1:1.2.13.dfsg-3

Versions of packages gcc-12 recommends:
ii  libc6-dev  2.37-12

Versions of packages gcc-12 suggests:
ii  gcc-12-doc       12.2.0-1
pn  gcc-12-locales   <none>
pn  gcc-12-multilib  <none>

-- no debconf information

Reply via email to