This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/51494] Legal program rejection - capturing "this" when using static method inside lambda
- From: "gcc-bugx at mailinator dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Mon, 04 Jun 2012 08:21:54 +0000
- Subject: [Bug c++/51494] Legal program rejection - capturing "this" when using static method inside lambda
- Auto-submitted: auto-generated
- References: <bug-51494-4@http.gcc.gnu.org/bugzilla/>
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51494
gcc-bugx at mailinator dot com changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |gcc-bugx at mailinator dot
| |com
--- Comment #4 from gcc-bugx at mailinator dot com 2012-06-04 08:21:54 UTC ---
Probably related error: this capture ignored on explicit instantiation.
--------------------8<---------------
struct A
{
static void f() {}
template <typename T>
void foo()
{
[this] () { f(); };
}
};
template void A::foo<int>();
-------------------->8---------------
Compiler version & output:
$ g++ -std=c++11 -c -v y.cc
Using built-in specs.
COLLECT_GCC=g++
Target: x86_64-unknown-linux-gnu
Configured with: ./configure --enable-languages=c,c++ --prefix=/home/x
Thread model: posix
gcc version 4.7.0 (GCC)
COLLECT_GCC_OPTIONS='-std=c++11' '-c' '-v' '-shared-libgcc' '-mtune=generic'
'-march=x86-64'
/home/x/libexec/gcc/x86_64-unknown-linux-gnu/4.7.0/cc1plus -quiet -v
-D_GNU_SOURCE y.cc -quiet -dumpbase y.cc -mtune=generic -march=x86-64 -auxbase
y -std=c++11 -version -o /tmp/ccdFvfri.s
GNU C++ (GCC) version 4.7.0 (x86_64-unknown-linux-gnu)
compiled by GNU C version 4.7.0, GMP version 4.3.2, MPFR version
3.0.0-p8, MPC version 0.9
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
ignoring nonexistent directory
"/home/x/lib/gcc/x86_64-unknown-linux-gnu/4.7.0/../../../../x86_64-unknown-linux-gnu/include"
#include "..." search starts here:
#include <...> search starts here:
/home/x/lib/gcc/x86_64-unknown-linux-gnu/4.7.0/../../../../include/c++/4.7.0
/home/x/lib/gcc/x86_64-unknown-linux-gnu/4.7.0/../../../../include/c++/4.7.0/x86_64-unknown-linux-gnu
/home/x/lib/gcc/x86_64-unknown-linux-gnu/4.7.0/../../../../include/c++/4.7.0/backward
/home/x/lib/gcc/x86_64-unknown-linux-gnu/4.7.0/include
/usr/local/include
/home/x/include
/home/x/lib/gcc/x86_64-unknown-linux-gnu/4.7.0/include-fixed
/usr/include
End of search list.
GNU C++ (GCC) version 4.7.0 (x86_64-unknown-linux-gnu)
compiled by GNU C version 4.7.0, GMP version 4.3.2, MPFR version
3.0.0-p8, MPC version 0.9
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
Compiler executable checksum: ...
y.cc: In instantiation of âA::foo() [with T = int]::<lambda()>â:
y.cc:8:4: required from âstruct A::foo() [with T = int]::<lambda()>â
y.cc:8:3: required from âvoid A::foo() [with T = int]â
y.cc:11:27: required from here
y.cc:8:17: error: âthisâ was not captured for this lambda function