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

Neil Booth neil at daikokuya.co.uk
Mon Aug 25 16:27:52 PDT 2008


Eli Friedman wrote:-

> Consider the following testcase:
> int a() {return 0;}
> int b() {return a(1);}
> 
> Calling b has undefined behavior per C99, but no diagnostics are required.
> 
> Consider the following testcase:
> int a(int);
> int a() {return 0;}
> This is a constraint violation per C99.
> 
> We currently map a() to FunctionTypeNoProto, and this has roughly the
> right behavior when we don't merge types.  However, by adding merge
> types, we conclude that a() has type a(int), which is clearly wrong,
> and leads to crashes trying to access non-existent parameter
> declarations.  But if we instead map a() to a FunctionTypeProto with
> no parameters, we incorrectly error out on the first example.

What type are you giving a()?  Since it doesn't have a well-defined
type according to the standard, I would have thought "erroneous type"
or somesuch would be appropriate.  Assuming you don't wish to give
meaning to all erroneous constructs (some you might as an extension
or relaxation of course) those without meaning must be flagged as
not having concrete meaning in some way to prevent later bogus
diagnostics and analyses, if nothing else.

Neil.



More information about the cfe-dev mailing list