This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/54348] confusing error reported for type mismatch in conditional expression : "error: no match for ternary 'operator?:' in 'false ?"


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;
}


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]