[Bug c++/54348] confusing error reported for type mismatch in conditional expression : "error: no match for ternary 'operator?:' in 'false ?"
redi at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Tue Aug 21 19:52:00 GMT 2012
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54348
--- Comment #2 from Jonathan Wakely <redi at gcc dot gnu.org> 2012-08-21 19:51:53 UTC ---
(In reply to comment #0)
> Shouldn't g++ be complaining about initializing a string with a list<string>
> rather than this cryptic "no match for ternary 'operator?:'" here ?
No, not really.
The object being initialized by the result of the condition expression is
irrelevant, the conditional expression isn't valid whether or not you're using
it to initialize another object.
In this reduced version it wouldn't make sense to refer to initializing any
object with any other:
struct A {} a;
struct B {} b;
void f()
{
false ? a : b;
}
More information about the Gcc-bugs
mailing list