The following code reproduces the Example in n3092 (FCD) 5.1.2/8, complete with the comments given there:
14:36:12 Paul bibbi...@jijou /cygdrive/d/CPPProjects/nano/gcc_bugs $cat _5_1_2_8.cpp // file: _5_1_2_8.cpp struct S2 { void f(int i); }; void S2::f(int i) { [&, i]{ }; // OK [&, &i]{ }; // error: i preceded by & when & is the default [=, this]{ }; // error: this when = is the default // [i, i]{ }; // error: i repeated } The fourth lambda-expression has been commented out to reflect the fact that gcc-4.5.0 correctly handles this as an error. The second and third - which should be errors according 5.1.2/8 - are left uncommented. gcc-4.5.0 compiles this code without issuing an error, thus not handling the following from 5.1.2/8 correctly: - "If a lambda-capture includes a capture-default that is &, the identifiers in the lambda capture shall not be preceded by &"; and - "If a lambda-capture includes a capture-default that is =, the lambda capture shall not contain this." 14:33:29 Paul bibbi...@jijou /cygdrive/d/CPPProjects/nano/gcc_bugs $make i686-pc-cygwin-gcc-4.5.0 -v -save-temps -Wall -std=c++0x -pedantic -c _5_1_2_8.cpp Using built-in specs. COLLECT_GCC=i686-pc-cygwin-gcc-4.5.0 COLLECT_LTO_WRAPPER=/opt/gcc-4.5.0/libexec/gcc/i686-pc-cygwin/4.5.0/lto-wrapper.exe Target: i686-pc-cygwin Configured with: ./configure --prefix=/opt/gcc-4.5.0 --enable-bootstrap --enable-version-specific-runtime-libs --enable-static --enable-shared --enable-shared-libgcc --disable-__cxa_atexit --with-gnu-ld --with-gnu-as --with-dwarf2 --disable-sjlj-exceptions --enable-languages=c,c++ --disable-symvers --enable-libgomp --enable-libssp --enable-threads=posix --with-arch-i686 --with-tune=generic Thread model: posix gcc version 4.5.0 (GCC) COLLECT_GCC_OPTIONS='-v' '-save-temps' '-Wall' '-std=c++0x' '-pedantic' '-c' '-mtune=generic' '-march=pentiumpro' /opt/gcc-4.5.0/libexec/gcc/i686-pc-cygwin/4.5.0/cc1plus.exe -E -quiet -v -D__CYGWIN32__ -D__CYGWIN__ -Dunix -D__unix__ -D__unix -idirafter /usr/lib/../include/w32api -idirafter ../../include/w32api _5_1_2_8.cpp -mtune=generic -march=pentiumpro -std=c++0x -Wall -pedantic -fpch-preprocess -o _5_1_2_8.ii ignoring nonexistent directory "/opt/gcc-4.5.0/lib/gcc/i686-pc-cygwin/4.5.0/../../../../i686-pc-cygwin/include" ignoring nonexistent directory "../../include/w32api" #include "..." search starts here: #include <...> search starts here: /opt/gcc-4.5.0/lib/gcc/i686-pc-cygwin/4.5.0/include/c++ /opt/gcc-4.5.0/lib/gcc/i686-pc-cygwin/4.5.0/include/c++/i686-pc-cygwin /opt/gcc-4.5.0/lib/gcc/i686-pc-cygwin/4.5.0/include/c++/backward /usr/local/include /opt/gcc-4.5.0/include /opt/gcc-4.5.0/lib/gcc/i686-pc-cygwin/4.5.0/include /opt/gcc-4.5.0/lib/gcc/i686-pc-cygwin/4.5.0/include-fixed /usr/include /usr/lib/../include/w32api End of search list. COLLECT_GCC_OPTIONS='-v' '-save-temps' '-Wall' '-std=c++0x' '-pedantic' '-c' '-mtune=generic' '-march=pentiumpro' /opt/gcc-4.5.0/libexec/gcc/i686-pc-cygwin/4.5.0/cc1plus.exe -fpreprocessed _5_1_2_8.ii -quiet -dumpbase _5_1_2_8.cpp -mtune=generic -march=pentiumpro -auxbase _5_1_2_8 -Wall -pedantic -std=c++0x -version -o _5_1_2_8.s GNU C++ (GCC) version 4.5.0 (i686-pc-cygwin) compiled by GNU C version 4.5.0, GMP version 4.3.2, MPFR version 2.4.1, MPC version 0.8.1 warning: GMP header version 4.3.2 differs from library version 4.3.1. warning: MPFR header version 2.4.1 differs from library version 2.4.1-p5. warning: MPC header version 0.8.1 differs from library version 0.8. GGC heuristics: --param ggc-min-expand=99 --param ggc-min-heapsize=129712 GNU C++ (GCC) version 4.5.0 (i686-pc-cygwin) compiled by GNU C version 4.5.0, GMP version 4.3.2, MPFR version 2.4.1, MPC version 0.8.1 warning: GMP header version 4.3.2 differs from library version 4.3.1. warning: MPFR header version 2.4.1 differs from library version 2.4.1-p5. warning: MPC header version 0.8.1 differs from library version 0.8. GGC heuristics: --param ggc-min-expand=99 --param ggc-min-heapsize=129712 Compiler executable checksum: 81a7a49c1fa28713ff621b6b856147c0 COLLECT_GCC_OPTIONS='-v' '-save-temps' '-Wall' '-std=c++0x' '-pedantic' '-c' '-mtune=generic' '-march=pentiumpro' as -v -o _5_1_2_8.o _5_1_2_8.s GNU assembler version 2.20.51 (i686-cygwin) using BFD version (GNU Binutils) 2.20.51.20100410 COMPILER_PATH=/opt/gcc-4.5.0/libexec/gcc/i686-pc-cygwin/4.5.0/:/opt/gcc-4.5.0/libexec/gcc/i686-pc-cygwin/4.5.0/:/opt/gcc-4.5.0/libexec/gcc/i686-pc-cygwin/:/opt/gcc-4.5.0/lib/gcc/i686-pc-cygwin/4.5.0/:/opt/gcc-4.5.0/lib/gcc/i686-pc-cygwin/ LIBRARY_PATH=/opt/gcc-4.5.0/lib/gcc/i686-pc-cygwin/4.5.0/:/opt/gcc-4.5.0/lib/gcc/i686-pc-cygwin/4.5.0/../../../:/lib/:/usr/lib/ COLLECT_GCC_OPTIONS='-v' '-save-temps' '-Wall' '-std=c++0x' '-pedantic' '-c' '-mtune=generic' '-march=pentiumpro' 14:33:31 Paul bibbi...@jijou /cygdrive/d/CPPProjects/nano/gcc_bugs $ 14:36:04 Paul bibbi...@jijou /cygdrive/d/CPPProjects/nano/gcc_bugs $cat _5_1_2_8.ii # 1 "_5_1_2_8.cpp" # 1 "<built-in>" # 1 "<command-line>" # 1 "_5_1_2_8.cpp" struct S2 { void f(int i); }; void S2::f(int i) { [&, i]{ }; [&, &i]{ }; [=, this]{ }; } -- Summary: [C++0x] gcc-4.5.0 does not fail invalid lambda captures (against n3092 5.1.2/8) Product: gcc Version: 4.5.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: paul dot bibbings at gmail dot com GCC host triplet: i686-pc-cygwin http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43831