From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 19634 invoked by alias); 22 Apr 2010 19:16:04 -0000 Received: (qmail 19309 invoked by uid 48); 22 Apr 2010 19:15:21 -0000 Date: Thu, 22 Apr 2010 19:16:00 -0000 Subject: [Bug c++/43856] New: [C++0x] gcc-4.5.0 fails to transform id-expression into class member access in lambda compound-statement X-Bugzilla-Reason: CC Message-ID: Reply-To: gcc-bugzilla@gcc.gnu.org To: gcc-bugs@gcc.gnu.org From: "paul dot bibbings at gmail dot com" Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2010-04/txt/msg02413.txt.bz2 When attempting to compile the following code taken directly from [expr.prim.lambda] 5.1.2/7 (n3092, FCD): 19:56:28 Paul Bibbings@JIJOU /cygdrive/d/CPPProjects/nano/gcc_bugs $cat _5_1_2_7.cpp // file: _5_1_2_7.cpp struct S1 { int x, y; int operator()(int); void f() { [=]()->int { return operator()(this->x + y); }; } }; gcc-4.5.0 fails to apply all aspects of the clause correctly: 5.1.2/7: "The lambda-expression’s compound-statement yields the function-body (8.4) of the function call operator, but for purposes of name lookup (3.4), determining the type and value of this (9.3.2) and transforming id-expressions referring to non-static class members into class member access expressions using (*this) (9.3.1), the compound-statement is considered in the context of the lambda-expression." Specifically, it fails in transforming operator()(this->x + y) into (*this).operator()(this->x + y). 19:56:37 Paul Bibbings@JIJOU /cygdrive/d/CPPProjects/nano/gcc_bugs $i686-pc-cygwin-gcc-4.5.0 -v -save-temps -Wall -std=c++0x -pedantic -c _5_1_2_7.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_7.cpp -mtune=generic -march=pentiumpro -std=c++0x -Wall -pedantic -fpch-preprocess -o _5_1_2_7.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_7.ii -quiet -dumpbase _5_1_2_7.cpp -mtune=generic -march=pentiumpro -auxbase _5_1_2_7 -Wall -pedantic -std=c++0x -version -o _5_1_2_7.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 GGC heuristics: --param ggc-min-expand=99 --param ggc-min-heapsize=129712 GNU C++ (GCC) version 4.5.0 (i686-pc-cygwin) Compiler executable checksum: 81a7a49c1fa28713ff621b6b856147c0 _5_1_2_7.cpp: In lambda function: _5_1_2_7.cpp:7:14: error: ‘this’ has incomplete type _5_1_2_7.cpp:7:9: error: forward declaration of ‘struct S1::f()::’ _5_1_2_7.cpp:7:14: note: candidate is: S1::f():: If the given code is augmented to include an explicit reference to (*this) on the invocation of op() in the return statement, as: struct S1 { int x, y; int operator()(int); void f() { [=]()->int { return (*this).operator()(this->x + y); }; } }; then compilation succeeds. 20:08:51 Paul Bibbings@JIJOU /cygdrive/d/CPPProjects/nano/gcc_bugs $cat _5_1_2_7.ii # 1 "_5_1_2_7.cpp" # 1 "" # 1 "" # 1 "_5_1_2_7.cpp" struct S1 { int x, y; int operator()(int); void f() { [=]()->int { return operator()(this->x + y); }; } }; -- Summary: [C++0x] gcc-4.5.0 fails to transform id-expression into class member access in lambda compound-statement 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=43856