This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/54348] confusing error reported for type mismatch in conditional expression : "error: no match for ternary 'operator?:' in 'false ?"
- From: "redi at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Tue, 21 Aug 2012 19:51:53 +0000
- Subject: [Bug c++/54348] confusing error reported for type mismatch in conditional expression : "error: no match for ternary 'operator?:' in 'false ?"
- Auto-submitted: auto-generated
- References: <bug-54348-4@http.gcc.gnu.org/bugzilla/>
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;
}