[cfe-dev] K&R style argument lists and the type system
Neil Booth
neil at daikokuya.co.uk
Tue Aug 26 07:58:55 PDT 2008
Chris Lattner wrote:-
> > Bleh, I think we have to encode the exact signature into the type
> > system somehow. Consider the following testcase:
> >
> > int a(x) float x; {return x;}
> > int b(int x) {return x;}
> > int c(int x) {return (x ? a : b)(1);}
> >
> > This is a constraint violation per C99, which would be completely
> > unintuitive to diagnose without encoding the fact that "a" takes float
> > into the type.
> >
> > gcc apparently screws up this case; it doesn't print a warning even
> > with -std=c99 -pedantic. Although, the standard is a bit screwy here.
>
> 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 :)
Neil.
More information about the cfe-dev
mailing list