On 05/07/2012 07:18 PM, Paolo Carlini wrote:
On 05/07/2012 07:16 PM, Jason Merrill wrote:
I don't think the diagnostic is meaningless; since a() is ill-formed, b() has type void.
Sure we do understand it ;)
But we ought to give a more helpful message when an expression used as a truth value has an unsuitable type.
Thus something much more general than the lambda context of the PR. Ok, I can see what I can do.
I think this is the minimal testcase we are looking for:

void foo();

void bar(int a, int b)
{
  if (foo() && a < b)
    ;
}

the error message is the same we see in PR 53158, thus:

a.cc:5:20: error: invalid operands of types ‘void’ and ‘int’ to binary ‘operator!=’
   if (foo() && a < b)

If I take out the 'a < b' subexpression, we get:

a.cc:5:12: error: could not convert ‘foo()’ from ‘void’ to ‘bool’
   if (foo())

Is this the error message we want to see for the former testcase, or we want something slightly different?

Thanks!
Paolo.

Reply via email to