[Bug c++/56710] New: Using reserved double underscore variable name in a lambda causes internal compiler error

noname at nurd dot se gcc-bugzilla@gcc.gnu.org
Sun Mar 24 14:24:00 GMT 2013


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56710

             Bug #: 56710
           Summary: Using reserved double underscore variable name in a
                    lambda causes internal compiler error
    Classification: Unclassified
           Product: gcc
           Version: 4.9.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: noname@nurd.se


When using any reserved double underscore prefix variable name within a lambda
combined with a non-double underscore variable with the same name will cause a
name lookup internal compiler error.

Minimal example:

int main()
{
    int t = 0;
    return [&]() -> int {int __t; __t = t; return __t; }();
}

command line and output from the latest git snapshot of 4.9.0:
(fyi. g++ 4.7.2-2ubuntu1 produces similar results but with less verbose output,
so the bug was likely introduced before or with 4.7.2)

$ g++ -v -save-temps -std=c++0x -o test test.cpp
Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=/usr/local/libexec/gcc/x86_64-unknown-linux-gnu/4.9.0/lto-wrapper
Target: x86_64-unknown-linux-gnu
Configured with: ./configure
Thread model: posix
gcc version 4.9.0 20130324 (experimental) (GCC) 
COLLECT_GCC_OPTIONS='-v' '-save-temps' '-std=c++11' '-o' 'test'
'-shared-libgcc' '-mtune=generic' '-march=x86-64'
 /usr/local/libexec/gcc/x86_64-unknown-linux-gnu/4.9.0/cc1plus -E -quiet -v
-imultilib . -imultiarch x86_64-linux-gnu -D_GNU_SOURCE test.cpp -mtune=generic
-march=x86-64 -std=c++11 -fpch-preprocess -o test.ii
ignoring nonexistent directory "/usr/local/include/x86_64-linux-gnu"
ignoring nonexistent directory
"/usr/local/lib/gcc/x86_64-unknown-linux-gnu/4.9.0/../../../../x86_64-unknown-linux-gnu/include"
#include "..." search starts here:
#include <...> search starts here:

/usr/local/lib/gcc/x86_64-unknown-linux-gnu/4.9.0/../../../../include/c++/4.9.0

/usr/local/lib/gcc/x86_64-unknown-linux-gnu/4.9.0/../../../../include/c++/4.9.0/x86_64-unknown-linux-gnu/.

/usr/local/lib/gcc/x86_64-unknown-linux-gnu/4.9.0/../../../../include/c++/4.9.0/backward
 /usr/local/lib/gcc/x86_64-unknown-linux-gnu/4.9.0/include
 /usr/local/include
 /usr/local/lib/gcc/x86_64-unknown-linux-gnu/4.9.0/include-fixed
 /usr/include/x86_64-linux-gnu
 /usr/include
End of search list.
COLLECT_GCC_OPTIONS='-v' '-save-temps' '-std=c++11' '-o' 'test'
'-shared-libgcc' '-mtune=generic' '-march=x86-64'
 /usr/local/libexec/gcc/x86_64-unknown-linux-gnu/4.9.0/cc1plus -fpreprocessed
test.ii -quiet -dumpbase test.cpp -mtune=generic -march=x86-64 -auxbase test
-std=c++11 -version -o test.s
GNU C++ (GCC) version 4.9.0 20130324 (experimental) (x86_64-unknown-linux-gnu)
    compiled by GNU C version 4.9.0 20130324 (experimental), GMP version 5.0.2,
MPFR version 3.1.0-p3, MPC version 0.9
GGC heuristics: --param ggc-min-expand=30 --param ggc-min-heapsize=4096
GNU C++ (GCC) version 4.9.0 20130324 (experimental) (x86_64-unknown-linux-gnu)
    compiled by GNU C version 4.9.0 20130324 (experimental), GMP version 5.0.2,
MPFR version 3.1.0-p3, MPC version 0.9
GGC heuristics: --param ggc-min-expand=30 --param ggc-min-heapsize=4096
Compiler executable checksum: 06fd05e24840af5f20c0ad55456ec1cf
test.cpp: In lambda function:
test.cpp:4:53: internal compiler error: in pop_binding, at cp/name-lookup.c:380
  return [&]() -> int {int __t; __t = t; return __t; }();
                                                     ^
0x6c1c4e pop_binding(tree_node*, tree_node*)
    ../.././gcc/cp/name-lookup.c:380
0x523427 poplevel(int, int, int)
    ../.././gcc/cp/decl.c:731
0x66fbb3 do_poplevel(tree_node*)
    ../.././gcc/cp/semantics.c:436
0x673cf9 finish_compound_stmt(tree_node*)
    ../.././gcc/cp/semantics.c:1287
0x603241 cp_parser_lambda_body
    ../.././gcc/cp/parser.c:8725
0x603241 cp_parser_lambda_expression
    ../.././gcc/cp/parser.c:8272
0x603241 cp_parser_primary_expression
    ../.././gcc/cp/parser.c:4087
0x604f78 cp_parser_postfix_expression
    ../.././gcc/cp/parser.c:5643
0x607545 cp_parser_unary_expression
    ../.././gcc/cp/parser.c:6711
0x60815b cp_parser_binary_expression
    ../.././gcc/cp/parser.c:7403
0x60860f cp_parser_assignment_expression
    ../.././gcc/cp/parser.c:7639
0x60a483 cp_parser_expression
    ../.././gcc/cp/parser.c:7801
0x601462 cp_parser_expression
    ../.././gcc/cp/parser.c:7840
0x601462 cp_parser_jump_statement
    ../.././gcc/cp/parser.c:10109
0x601462 cp_parser_statement
    ../.././gcc/cp/parser.c:8843
0x601cde cp_parser_statement_seq_opt
    ../.././gcc/cp/parser.c:9207
0x601e26 cp_parser_compound_statement
    ../.././gcc/cp/parser.c:9161
0x613253 cp_parser_function_body
    ../.././gcc/cp/parser.c:17775
0x613253 cp_parser_ctor_initializer_opt_and_function_body
    ../.././gcc/cp/parser.c:17811
0x6142df cp_parser_function_definition_after_declarator
    ../.././gcc/cp/parser.c:21786
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See <http://gcc.gnu.org/bugs.html> for instructions.



More information about the Gcc-bugs mailing list