http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55607
Bug #: 55607
Summary: "undefined reference" with rvalue lambda at
non-namespace scope
Classification: Unclassified
Product: gcc
Version: 4.7.2
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
AssignedTo: [email protected]
ReportedBy: [email protected]
Created attachment 28885
--> http://gcc.gnu.org/bugzilla/attachment.cgi?id=28885
Reproducible test case
Compiling the attached test case with g++ 4.7.2 (g++-4.7 -std=c++11
ud-lambda.cpp) gives the following error:
/tmp/ccNp8EwS.o: In function `foo::bar()::{lambda()#1}::operator void (*)()()
const':
ud-lambda.cpp:(.text._ZZN3foo3barEvENKUlvE_cvPFvvEEv[_ZZN3foo3barEvENKUlvE_cvPFvvEEv]+0x4):
undefined reference to `foo::bar()::{lambda()#1}::_FUN()'
collect2: error: ld returned 1 exit status
The error did not occur with 4.7.0.
The demo program shows two variants using "#if" (since I apparently can't add
two separate attachments here). Both show the same problem. I'm not sure which
one is more useful.
The important points are that a lambda is used as an rvalue -- in the first
case due to the "+", in the second case due to the conversion to a function
pointer -- and that it's done in a nested scope (here, struct foo).
I suppose the test case is correct, but in case it's not, I'd expect a compiler
error, not a link-time undefined reference.
% g++-4.7 -v
COLLECT_GCC=g++-4.7
COLLECT_LTO_WRAPPER=/usr/lib/gcc/i486-linux-gnu/4.7/lto-wrapper
Target: i486-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Debian 4.7.2-4'
--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 --enable-targets=all --with-arch-32=i586
--with-tune=generic --enable-checking=release --build=i486-linux-gnu
--host=i486-linux-gnu --target=i486-linux-gnu
Thread model: posix
gcc version 4.7.2 (Debian 4.7.2-4)