http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54557

--- Comment #1 from Daniel Krügler <daniel.kruegler at googlemail dot com> 
2012-09-12 20:54:26 UTC ---
The compiler behaviour looks correct to me. The difference of the lambda
expressions in bar and foo3 compared to the other two is that these are
capture-free lambdas and thus have a conversion function to function pointer. 

Each lambda expression corresponds to a unique class type, so what we have in
foo1 and foo2 can be compared with the following class-example:

struct A{};
struct B{};
void f() {
  false ? A() : B();
}

This expression has no common type for the conditional operator and is
ill-formed.

What we have in bar and foo3 can be compared with the following class-example :

struct A{ typedef void (*F)(); operator F(); };
struct B{ typedef void (*F)(); operator F(); };
void f() {
  false ? A() : B();
}

This is well-formed, because in the last step of the conditional operator
conversion attempts (5.16p5), more general conversions are attempted and these
find the common pointer to function.

The current compiler behaviour gives a correct diagnostics and I see nothing
wrong with it.

Reply via email to