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

            Bug ID: 124544
           Summary: [reflection] ICE in finish_member_declaration, at
                    cp/semantics.cc:4258
           Product: gcc
           Version: 16.0
            Status: UNCONFIRMED
          Keywords: c++26, ice-on-valid-code
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: alexey.saldyrkine at gmail dot com
  Target Milestone: ---

Created attachment 63948
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=63948&action=edit
Preprocessed source

ICE occurs when trying to instantiate a partial specialization of a class with
a reflection of a type and a reflection of an alias of the type as a template
parameter, and calling a static function.
ICE does not occur if the class is a normal template and not a partial
specialization of another class.
ICE does not occur if “int” is used instead of “alias_t<int>”.

```
#include <meta>

namespace meta = std::meta;

template <meta::info class_refl, typename TP>
struct partial_spec {};

template <meta::info class_refl>
struct partial_spec<class_refl, char> {
    static void func(){}
};

template<typename T>
using alias_t = T;

int main() {
    partial_spec<^^int, char>::func();

    using alias = alias_t<int>;
    partial_spec<^^alias, char>::func(); 
}
```

<source>: In instantiation of 'struct partial_spec<^^alias, char>':
<source>:20:32:   required from here
   20 |     partial_spec<^^alias, char>::func();
      |                                ^~
<source>:9:39: internal compiler error: in finish_member_declaration, at
cp/semantics.cc:4258
    9 | struct partial_spec<class_refl, char> {
      |                                       ^
0x2965fc8 diagnostics::context::diagnostic_impl(rich_location*,
diagnostics::metadata const*, diagnostics::option_id, char const*,
__va_list_tag (*) [1], diagnostics::kind)
        ???:0
0x295ac0b internal_error(char const*, ...)
        ???:0
0xb21de0 fancy_abort(char const*, int, char const*)
        ???:0
0xdd8923 instantiate_class_template(tree_node*)
        ???:0
0xd6e183 c_parse_file()
        ???:0
0xef8629 c_common_parse_file()
        ???:0

Godbolt link: https://godbolt.org/z/5sc9q185W

## GCC Version, system, and options:
```
Using built-in specs.
COLLECT_GCC=/opt/compiler-explorer/gcc-snapshot/bin/g++
Target: x86_64-linux-gnu
Configured with: ../gcc-trunk-20260316/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,objc,obj-c++,go,d,rust,m2,cobol,algol68
--enable-ld=yes --enable-gold=yes --enable-libstdcxx-time=yes
--enable-linker-build-id --enable-lto --enable-plugins --enable-threads=posix
--with-pkgversion=Compiler-Explorer-Build-gcc-172f92a464f64b3d6e0a6835882c6cbab36ffc3e-binutils-2.44
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 16.0.1 20260315 (experimental)
(Compiler-Explorer-Build-gcc-172f92a464f64b3d6e0a6835882c6cbab36ffc3e-binutils-2.44)
 
```
## Command line:
```
-quiet -v -imultiarch x86_64-linux-gnu -iprefix
/cefs/c0/c0870943404e3c97880a2e09_gcc-trunk-20260316/bin/../lib/gcc/x86_64-linux-gnu/16.0.1/
-D_GNU_SOURCE <source> -quiet -dumpdir /app/ -dumpbase output.cpp -dumpbase-ext
.cpp -masm=intel -mtune=generic -march=x86-64 -g -O3 -Wall -Wextra -std=c++26
-version -fdiagnostics-color=always -fno-verbose-asm -freflection -o
/app/output.s
```
  • [Bug c++/124544] New: [ref... alexey.saldyrkine at gmail dot com via Gcc-bugs

Reply via email to