This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Is this meant to compile?
- From: "Zack Weinberg" <zack at codesourcery dot com>
- To: Chris Lattner <sabre at nondot dot org>
- Cc: gcc at gcc dot gnu dot org
- Date: Wed, 20 Aug 2003 12:09:11 -0700
- Subject: Re: Is this meant to compile?
- References: <Pine.LNX.4.44.0308201350290.10566-100000@nondot.org>
Chris Lattner <sabre@nondot.org> writes:
> This testcase:
>
> -------------------------
> static int foo(int);
> static int foo(C)
> char C;
> { return C; }
>
> void test() { foo(7); }
> ------------------
>
> Currently compiles with mainline gcc, yet this testcase:
>
> ------------------
>
> static int foo(int);
>
> static int foo(char C) { return C; }
> void test() { foo(7); }
>
>
> ------------------
>
> Produces these errors:
> 2003-08-20-PrototypeMismatch.c:7: error: conflicting types for 'foo'
> 2003-08-20-PrototypeMismatch.c:3: error: previous declaration of 'foo'
>
> Is this desired behavior?
Yes. In old-style function definitions, any argument narrower than an
'int' gets promoted to 'int'. (This is not the same as the widening
required by some ABIs for such arguments, which is transparent to the
language.)
zw