Created attachment 27890 [details] Preprocessed source output from gcc enum class Enum { VALUE_1, VALUE_2 }; template <class T> struct Struct { Struct() { const auto func = [=] { return (e == Enum::VALUE_2) }; (void)func; } Enum e; }; int main() { } ------------------------------------------------------------------------ /tmp$ g++ -v -save-temps -std=c++11 test.cpp Using built-in specs. COLLECT_GCC=g++ COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/4.7/lto-wrapper Target: x86_64-linux-gnu Configured with: ../src/configure -v --with-pkgversion='Ubuntu/Linaro 4.7.0-1ubuntu1' --with-bugurl=file:///usr/share/doc/gcc-4.7/README.Bugs --enable-languages=c,c++,go,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-4.7 --enable-shared --enable-linker-build-id --with-system-zlib --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.7 --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --enable-gnu-unique-object --enable-plugin --enable-objc-gc --disable-werror --with-arch-32=i686 --with-tune=generic --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu Thread model: posix gcc version 4.7.0 (Ubuntu/Linaro 4.7.0-1ubuntu1) COLLECT_GCC_OPTIONS='-v' '-save-temps' '-std=c++11' '-shared-libgcc' '-mtune=generic' '-march=x86-64' /usr/lib/gcc/x86_64-linux-gnu/4.7/cc1plus -E -quiet -v -imultiarch x86_64-linux-gnu -D_GNU_SOURCE test.cpp -mtune=generic -march=x86-64 -std=c++11 -fpch-preprocess -fstack-protector -o test.ii ignoring nonexistent directory "/usr/local/include/x86_64-linux-gnu" ignoring nonexistent directory "/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../../x86_64-linux-gnu/include" #include "..." search starts here: #include <...> search starts here: /usr/include/c++/4.7 /usr/include/c++/4.7/x86_64-linux-gnu /usr/include/c++/4.7/backward /usr/lib/gcc/x86_64-linux-gnu/4.7/include /usr/local/include /usr/lib/gcc/x86_64-linux-gnu/4.7/include-fixed /usr/include/x86_64-linux-gnu /usr/include End of search list. COLLECT_GCC_OPTIONS='-v' '-save-temps' '-std=c++11' '-shared-libgcc' '-mtune=generic' '-march=x86-64' /usr/lib/gcc/x86_64-linux-gnu/4.7/cc1plus -fpreprocessed test.ii -quiet -dumpbase test.cpp -mtune=generic -march=x86-64 -auxbase test -std=c++11 -version -fstack-protector -o test.s GNU C++ (Ubuntu/Linaro 4.7.0-1ubuntu1) version 4.7.0 (x86_64-linux-gnu) compiled by GNU C version 4.7.0, GMP version 5.0.2, MPFR version 3.1.0-p3, MPC version 0.9 GGC heuristics: --param ggc-min-expand=98 --param ggc-min-heapsize=127391 GNU C++ (Ubuntu/Linaro 4.7.0-1ubuntu1) version 4.7.0 (x86_64-linux-gnu) compiled by GNU C version 4.7.0, GMP version 5.0.2, MPFR version 3.1.0-p3, MPC version 0.9 GGC heuristics: --param ggc-min-expand=98 --param ggc-min-heapsize=127391 Compiler executable checksum: ebe4fd45b8b9c3fd6dc0cfc73cec8259 test.cpp: In lambda function: test.cpp:14:32: internal compiler error: Segmentation fault Please submit a full bug report, with preprocessed source if appropriate. See <file:///usr/share/doc/gcc-4.7/README.Bugs> for instructions. Preprocessed source stored into /tmp/ccmDN5TQ.out file, please attach this to your bugreport.
We hit this bug when trying to compile one of our new projects. I've created a minimal test case very similar to the one in the report. The bug doesn't hit on 4.6.3 nor on Visual Studio, but gcc 4.7 and 4.8 segfault.
Created attachment 29310 [details] Another reproduction Minimal test case based on actual code that's compiling correctly with both gcc 4.6.3 as well as Visual Studio. $ /opt/gcc-4.8/bin/g++ -v -save-temps -std=c++11 foo.cpp Using built-in specs. COLLECT_GCC=/opt/gcc-4.8/bin/g++ COLLECT_LTO_WRAPPER=/opt/gcc-4.8/libexec/gcc/x86_64-unknown-linux-gnu/4.8.0/lto-wrapper Target: x86_64-unknown-linux-gnu Configured with: ./configure --prefix=/opt/gcc-4.8 Thread model: posix gcc version 4.8.0 20130127 (experimental) (GCC) COLLECT_GCC_OPTIONS='-v' '-save-temps' '-std=c++11' '-shared-libgcc' '-mtune=generic' '-march=x86-64' /opt/gcc-4.8/libexec/gcc/x86_64-unknown-linux-gnu/4.8.0/cc1plus -E -quiet -v -D_GNU_SOURCE foo.cpp -mtune=generic -march=x86-64 -std=c++11 -fpch-preprocess -o foo.ii ignoring nonexistent directory "/opt/gcc-4.8/lib/gcc/x86_64-unknown-linux-gnu/4.8.0/../../../../x86_64-unknown-linux-gnu/include" #include "..." search starts here: #include <...> search starts here: /opt/gcc-4.8/lib/gcc/x86_64-unknown-linux-gnu/4.8.0/../../../../include/c++/4.8.0 /opt/gcc-4.8/lib/gcc/x86_64-unknown-linux-gnu/4.8.0/../../../../include/c++/4.8.0/x86_64-unknown-linux-gnu /opt/gcc-4.8/lib/gcc/x86_64-unknown-linux-gnu/4.8.0/../../../../include/c++/4.8.0/backward /opt/gcc-4.8/lib/gcc/x86_64-unknown-linux-gnu/4.8.0/include /usr/local/include /opt/gcc-4.8/include /opt/gcc-4.8/lib/gcc/x86_64-unknown-linux-gnu/4.8.0/include-fixed /usr/include End of search list. COLLECT_GCC_OPTIONS='-v' '-save-temps' '-std=c++11' '-shared-libgcc' '-mtune=generic' '-march=x86-64' /opt/gcc-4.8/libexec/gcc/x86_64-unknown-linux-gnu/4.8.0/cc1plus -fpreprocessed foo.ii -quiet -dumpbase foo.cpp -mtune=generic -march=x86-64 -auxbase foo -std=c++11 -version -o foo.s GNU C++ (GCC) version 4.8.0 20130127 (experimental) (x86_64-unknown-linux-gnu) compiled by GNU C version 4.8.0 20130127 (experimental), GMP version 5.0.2, MPFR version 3.1.0, MPC version 0.9 GGC heuristics: --param ggc-min-expand=30 --param ggc-min-heapsize=4096 GNU C++ (GCC) version 4.8.0 20130127 (experimental) (x86_64-unknown-linux-gnu) compiled by GNU C version 4.8.0 20130127 (experimental), GMP version 5.0.2, MPFR version 3.1.0, MPC version 0.9 GGC heuristics: --param ggc-min-expand=30 --param ggc-min-heapsize=4096 Compiler executable checksum: e8e88d7616898e4a81392bc45bc1dc95 foo.cpp: In lambda function: foo.cpp:15:12: internal compiler error: Segmentation fault if(e == enum_0) ^ 0xa7db9f crash_signal ../.././gcc/toplev.c:332 0x692c80 lvalue_kind(tree_node const*) ../.././gcc/cp/tree.c:146 0x6932a0 lvalue_kind(tree_node const*) ../.././gcc/cp/tree.c:101 0x693808 lvalue_p(tree_node const*) ../.././gcc/cp/tree.c:267 0x4fd710 standard_conversion ../.././gcc/cp/call.c:1102 0x503cf3 implicit_conversion ../.././gcc/cp/call.c:1694 0x5075d3 build_builtin_candidate ../.././gcc/cp/call.c:2151 0x508b60 add_builtin_candidates ../.././gcc/cp/call.c:2818 0x513e3b build_new_op_1 ../.././gcc/cp/call.c:5177 0x514c57 build_new_op(unsigned int, tree_code, int, tree_node*, tree_node*, tree_node*, tree_node**, int) ../.././gcc/cp/call.c:5444 0x626962 build_x_binary_op(unsigned int, tree_code, tree_node*, tree_code, tree_node*, tree_code, tree_node**, int) ../.././gcc/cp/typeck.c:3686 0x606b15 cp_parser_binary_expression ../.././gcc/cp/parser.c:7476 0x606e45 cp_parser_assignment_expression ../.././gcc/cp/parser.c:7584 0x608c42 cp_parser_expression ../.././gcc/cp/parser.c:7735 0x617a32 cp_parser_condition ../.././gcc/cp/parser.c:9410 0x5ff4c2 cp_parser_selection_statement ../.././gcc/cp/parser.c:9187 0x5ff4c2 cp_parser_statement ../.././gcc/cp/parser.c:8756 0x60067e cp_parser_statement_seq_opt ../.././gcc/cp/parser.c:9133 0x601bb5 cp_parser_lambda_body ../.././gcc/cp/parser.c:8647 0x601bb5 cp_parser_lambda_expression ../.././gcc/cp/parser.c:8188 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.
Yes, this is a regression. Let's add Jason in CC.
Started with http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=174499 enum E { F }; template <typename A> struct C { E e; void f () { auto l = [&](void)->void { if (e == F) return; }; } };
Author: jason Date: Wed Feb 6 04:24:18 2013 New Revision: 195781 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=195781 Log: PR c++/54122 * tree.c (lvalue_kind) [INDIRECT_REF]: Don't check for METHOD_TYPE. Added: trunk/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-this7.C Modified: trunk/gcc/cp/ChangeLog trunk/gcc/cp/tree.c
*** Bug 52613 has been marked as a duplicate of this bug. ***
*** Bug 52619 has been marked as a duplicate of this bug. ***
*** Bug 54403 has been marked as a duplicate of this bug. ***
Author: jason Date: Wed Feb 6 13:42:06 2013 New Revision: 195806 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=195806 Log: PR c++/54122 * tree.c (lvalue_kind) [INDIRECT_REF]: Don't check for METHOD_TYPE. Added: branches/gcc-4_7-branch/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-this7.C Modified: branches/gcc-4_7-branch/gcc/cp/ChangeLog branches/gcc-4_7-branch/gcc/cp/tree.c
Fixed.
*** Bug 55076 has been marked as a duplicate of this bug. ***