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

            Bug ID: 66619
           Summary: Internal compiler error: variable template deduced by
                    template argument deduction
           Product: gcc
           Version: 6.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: david.godfrey99 at gmail dot com
  Target Milestone: ---

This bug is two-fold. GCC trunk gives an ICE when val is instantiated with an
lvalue reference:

int y;

template<class T>
T val = y;

int main() {
    auto&& x = val<int&>;
}

######################################################

prog.cc: In function 'int main()':
prog.cc:7:16: internal compiler error: in convert_like_real, at cp/call.c:6485
     auto&& x = val<int&>;
                ^
0x5a8cd6 convert_like_real
        /home/heads/gcc/gcc-source/gcc/cp/call.c:6485
0x5b15a1 initialize_reference(tree_node*, tree_node*, int, int)
        /home/heads/gcc/gcc-source/gcc/cp/call.c:9732
0x5b9188 grok_reference_init
        /home/heads/gcc/gcc-source/gcc/cp/decl.c:5008
0x5b9188 check_initializer
        /home/heads/gcc/gcc-source/gcc/cp/decl.c:5900
0x5ce24c cp_finish_decl(tree_node*, tree_node*, bool, tree_node*, int)
        /home/heads/gcc/gcc-source/gcc/cp/decl.c:6619
0x646978 cp_parser_init_declarator
        /home/heads/gcc/gcc-source/gcc/cp/parser.c:17316
0x648763 cp_parser_simple_declaration
        /home/heads/gcc/gcc-source/gcc/cp/parser.c:11608
0x62b2c3 cp_parser_block_declaration
        /home/heads/gcc/gcc-source/gcc/cp/parser.c:11482
0x62bdd1 cp_parser_declaration_statement
        /home/heads/gcc/gcc-source/gcc/cp/parser.c:11109
0x62cb0a cp_parser_statement
        /home/heads/gcc/gcc-source/gcc/cp/parser.c:9810
0x62d142 cp_parser_statement_seq_opt
        /home/heads/gcc/gcc-source/gcc/cp/parser.c:10088
0x62d273 cp_parser_compound_statement
        /home/heads/gcc/gcc-source/gcc/cp/parser.c:10042
0x64538b cp_parser_function_body
        /home/heads/gcc/gcc-source/gcc/cp/parser.c:19221
0x64538b cp_parser_ctor_initializer_opt_and_function_body
        /home/heads/gcc/gcc-source/gcc/cp/parser.c:19257
0x645eb0 cp_parser_function_definition_after_declarator
        /home/heads/gcc/gcc-source/gcc/cp/parser.c:23517
0x646d5e cp_parser_function_definition_from_specifiers_and_declarator
        /home/heads/gcc/gcc-source/gcc/cp/parser.c:23429
0x646d5e cp_parser_init_declarator
        /home/heads/gcc/gcc-source/gcc/cp/parser.c:17089
0x648763 cp_parser_simple_declaration
        /home/heads/gcc/gcc-source/gcc/cp/parser.c:11608
0x62b2c3 cp_parser_block_declaration
        /home/heads/gcc/gcc-source/gcc/cp/parser.c:11482
0x625425 cp_parser_declaration
        /home/heads/gcc/gcc-source/gcc/cp/parser.c:11379

######################################################

This second example gives an error that doesn't make sense. Instantiate val
with an rvalue reference:

template<class T>
T val = 0;

int main() {
    auto&& x = val<int&&>;
}

prog.cc: In function 'int main()':
prog.cc:7:16: error: cannot bind 'int&&' lvalue to 'int&&'
     auto&& x = val<int&&>;

######################################################

Using built-in specs.
COLLECT_GCC=/usr/local/gcc-head/bin/g++
COLLECT_LTO_WRAPPER=/usr/local/gcc-head/libexec/gcc/x86_64-unknown-linux-gnu/6.0.0/lto-wrapper
Target: x86_64-unknown-linux-gnu
Configured with: /home/heads/gcc/gcc-source/configure
--prefix=/usr/local/gcc-head --enable-languages=c,c++ --enable-lto
--disable-multilib --without-ppl --without-cloog-ppl --enable-checking=release
--disable-nls
Thread model: posix
gcc version 6.0.0 20150621 (experimental) (GCC) 
COLLECT_GCC_OPTIONS='-o' 'prog.exe' '-std=gnu++1z' '-I' '/usr/local/sprout'
'-I' '/usr/local/boost-1.58.0/include' '-L/usr/local/boost-1.58.0/lib' '-Wall'
'-Wextra' '-v' '-shared-libgcc' '-mtune=generic' '-march=x86-64'
 /usr/local/gcc-head/libexec/gcc/x86_64-unknown-linux-gnu/6.0.0/cc1plus -quiet
-v -I /usr/local/sprout -I /usr/local/boost-1.58.0/include -imultiarch
x86_64-linux-gnu -D_GNU_SOURCE prog.cc -quiet -dumpbase prog.cc -mtune=generic
-march=x86-64 -auxbase prog -Wall -Wextra -std=gnu++1z -version -o
/tmp/cc38EvaY.s
GNU C++14 (GCC) version 6.0.0 20150621 (experimental)
(x86_64-unknown-linux-gnu)
        compiled by GNU C version 6.0.0 20150621 (experimental), GMP version
5.1.2, MPFR version 3.1.2, MPC version 1.0.1

Reply via email to