This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/54557] New: [c++ lambda] error in assigning lambda expr though "operator?:" while catching
- From: "vincenzo.innocente at cern dot ch" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Wed, 12 Sep 2012 11:29:10 +0000
- Subject: [Bug c++/54557] New: [c++ lambda] error in assigning lambda expr though "operator?:" while catching
- Auto-submitted: auto-generated
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54557
Bug #: 54557
Summary: [c++ lambda] error in assigning lambda expr though
"operator?:" while catching
Classification: Unclassified
Product: gcc
Version: 4.8.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: vincenzo.innocente@cern.ch
in this example
foo1 and foo2 do not compile, bar and foo3 do.
cat iflamda.cc
struct A {
int q;
bool sel;
bool bar(int i, int j) const;
bool foo1(int i, int j) const;
bool foo2(int i, int j) const;
bool foo3(int i, int j) const;
};
bool A:: bar(int i, int j) const {
auto f = sel ? [](int a, int b) { return a<b;} :
[](int a, int b) { return b<a;};
return f(i,j);
}
bool A::foo1(int i, int j) const {
auto f = sel ? [this](int a, int b) { return a<b;} :
[this](int a, int b) { return a<b+this->q;};
return f(i,j);
}
bool A::foo2(int i, int j) const {
int k = q;
auto f = sel ? [k](int a, int b) { return a<b;} :
[k](int a, int b) { return a<b+k;};
return f(i,j);
}
bool A::foo3(int i, int j) const {
auto f = sel ? [](int a, int b,int) { return a<b;} :
[](int a, int b, int k) { return a<b+k;};
return f(i,j,q);
}
Vincenzos-MacBook-Pro:ctest innocent$ c++ -O2 -std=gnu++11 -c iflamda.cc
iflamda.cc: In member function âbool A::foo1(int, int) constâ:
iflamda.cc:24:60: error: no match for ternary âoperator?:â (operand types are
âboolâ, âA::foo1(int, int) const::__lambda2â, and âA::foo1(int, int)
const::__lambda3â)
[this](int a, int b) { return a<b+this->q;};
^
iflamda.cc: In member function âbool A::foo2(int, int) constâ:
iflamda.cc:33:51: error: no match for ternary âoperator?:â (operand types are
âboolâ, âA::foo2(int, int) const::__lambda4â, and âA::foo2(int, int)
const::__lambda5â)
[k](int a, int b) { return a<b+k;};
^
Vincenzos-MacBook-Pro:ctest innocent$ c++ -v
Using built-in specs.
COLLECT_GCC=c++
COLLECT_LTO_WRAPPER=/usr/local/libexec/gcc/x86_64-apple-darwin12.1.0/4.8.0/lto-wrapper
Target: x86_64-apple-darwin12.1.0
Configured with: ./configure --enable-languages=c,c++,fortran
--disable-multilib --disable-bootstrap --enable-lto -disable-libitm
Thread model: posix
gcc version 4.8.0 20120912 (experimental) [trunk revision 191215] (GCC)