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

            Bug ID: 116323
           Summary: ICE: tree check: expected record_type or union_type or
                    qual_union_type, have bound_template_template_parm in
                    access_in_type, at cp/search.cc:663
           Product: gcc
           Version: 15.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: iamanonymous.cs at gmail dot com
  Target Milestone: ---
            Target: x86_64

*******************************************************************************
The compiler produces a internal compiler error during tree_check_failed when
compiling the provided code with the specified options. 
The issue can also be reproduced on Compiler Explorer.

*******************************************************************************
OS and Platform:
# uname -a
Linux ubuntu 4.15.0-213-generic #224-Ubuntu SMP Mon Jun 19 13:30:12 UTC 2023
x86_64 x86_64 x86_64 GNU/Linux
*******************************************************************************
# g++ -v
Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=/home/gcc-set/gcc24-7-24/gccbin/libexec/gcc/x86_64-pc-linux-gnu/15.0.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: /home/gcc-set/gcc24-7-24/configure
--prefix=/home/gcc-set/gcc24-7-24/gccbin --enable-languages=c,c++,fortran,go
--disable-multilib
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 15.0.0 20240724 (experimental) (GCC) 
*******************************************************************************
Program: 
# cat 1.cpp
class A { enum Enum{}; };

template<typename E, template<typename> class Alloc>
class B :private Alloc<E>,private A{ };

template<typename E, template<typename>class Alloc>
int B<E, Alloc>::foo( Enum m) { }
*******************************************************************************
Command Lines:
# g++ 1.cpp -O2 -ffunction-sections -fdata-sections -fno-rtti -fno-exceptions
-fno-stack-protector -DNDEBUG -Wall -Wextra -Werror -Wno-unused-function
-Wno-deprecated -Wno-sign-compare -pedantic -std=c++11
1.cpp:7:5: error: no declaration matches ‘int B<E, Alloc>::foo(A::Enum)’
    7 | int B<E, Alloc>::foo( Enum m) { }
      |     ^~~~~~~~~~~
1.cpp:7:5: note: no functions named ‘int B<E, Alloc>::foo(A::Enum)’
1.cpp:4:7: note: ‘class B<E, Alloc>’ defined here
    4 | class B :private Alloc<E>,private A{ };
      |       ^
1.cpp:7:23: internal compiler error: tree check: expected record_type or
union_type or qual_union_type, have bound_template_template_parm in
access_in_type, at cp/search.cc:663
    7 | int B<E, Alloc>::foo( Enum m) { }
      |                       ^~~~
0x27f432e internal_error(char const*, ...)
        /home/gcc-set/gcc24-7-24/gcc/diagnostic-global-context.cc:491
0x9b4ae6 tree_check_failed(tree_node const*, char const*, int, char const*,
...)
        /home/gcc-set/gcc24-7-24/gcc/tree.cc:9001
0x85ba7b tree_check3(tree_node*, char const*, int, char const*, tree_code,
tree_code, tree_code)
        /home/gcc-set/gcc24-7-24/gcc/tree.h:3672
0x85ba7b access_in_type
        /home/gcc-set/gcc24-7-24/gcc/cp/search.cc:663
0xd26e89 get_parent_with_private_access(tree_node*, tree_node*)
        /home/gcc-set/gcc24-7-24/gcc/cp/search.cc:168
0xd2aa6a enforce_access
        /home/gcc-set/gcc24-7-24/gcc/cp/semantics.cc:394
0xd2c0e0 perform_access_checks(vec<deferred_access_check, va_gc, vl_embed>*,
int)
        /home/gcc-set/gcc24-7-24/gcc/cp/semantics.cc:442
0xca3cd8 cp_parser_function_definition_from_specifiers_and_declarator
        /home/gcc-set/gcc24-7-24/gcc/cp/parser.cc:32886
0xca3cd8 cp_parser_init_declarator
        /home/gcc-set/gcc24-7-24/gcc/cp/parser.cc:23546
0xcabb3c cp_parser_single_declaration
        /home/gcc-set/gcc24-7-24/gcc/cp/parser.cc:33410
0xcabd9e cp_parser_template_declaration_after_parameters
        /home/gcc-set/gcc24-7-24/gcc/cp/parser.cc:33069
0xcabd9e cp_parser_explicit_template_declaration
        /home/gcc-set/gcc24-7-24/gcc/cp/parser.cc:33238
0xcb5bde cp_parser_declaration
        /home/gcc-set/gcc24-7-24/gcc/cp/parser.cc:15681
0xcb678a cp_parser_toplevel_declaration
        /home/gcc-set/gcc24-7-24/gcc/cp/parser.cc:15785
0xcb678a cp_parser_translation_unit
        /home/gcc-set/gcc24-7-24/gcc/cp/parser.cc:5301
0xcb678a c_parse_file()
        /home/gcc-set/gcc24-7-24/gcc/cp/parser.cc:51792
0xe0f6f1 c_common_parse_file()
        /home/gcc-set/gcc24-7-24/gcc/c-family/c-opts.cc:1315
Please submit a full bug report, with preprocessed source (by using
-freport-bug).
Please include the complete backtrace with any bug report.
See <https://gcc.gnu.org/bugs/> for instructions.


*******************************************************************************

Also ICE on trunk, compiler explorer:https://godbolt.org/z/cqvKG6Kns

*******************************************************************************

Reply via email to