[cfe-dev] K&R style argument lists and the type system

Neil Booth neil at daikokuya.co.uk
Tue Aug 26 15:23:00 PDT 2008

Chris Lattner wrote:-

>>> Are you sure this is a constraint violation?  Of what rule?
>> My front end gives
>> "/tmp/bug.c", line 3: error: expressions of types "int (*)()" and
>> 	"int (*)(int)" cannot be used together in a conditional expression
>> int c(int x) {return (x ? a : b)(1);}
>>                            ^
>> Which maybe gives a clue :)
> Ok, so this is simple and consistent.  The type of 'a' is int().
> Incidentally Neil, it is somewhat strange that you warn about types  
> after promotions.  The "true" part of the expression has type "int()"  
> not "int(*)()".  The user isn't using an expression of type "int(*)()"  
> with the conditional expression, they are using a raw function.

I don't see any value in referring to original types and it may
even engender confusion with the user thinking the compiler is
giving an error because it is missing some of the necessary semantic
analysis rather than because there is a type mismatch.

Comeau gives a very similar diagnostic with the same types stated.  The
decayed types are the ones that the semantics apply to.


More information about the cfe-dev mailing list