This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: [RFC] PR61300 K&R incoming args
- From: Richard Biener <richard dot guenther at gmail dot com>
- To: "Joseph S. Myers" <joseph at codesourcery dot com>,Florian Weimer <fweimer at redhat dot com>
- Cc: gcc at gcc dot gnu dot org
- Date: Tue, 03 Jun 2014 09:57:16 +0200
- Subject: Re: [RFC] PR61300 K&R incoming args
- Authentication-results: sourceware.org; auth=none
- References: <20140526073809 dot GA6679 at bubble dot grove dot modra dot org> <5388DA76 dot 3060103 at redhat dot com> <20140531065625 dot GY6679 at bubble dot grove dot modra dot org> <538C4B49 dot 2080507 at redhat dot com> <Pine dot LNX dot 4 dot 64 dot 1406022125340 dot 27099 at digraph dot polyomino dot org dot uk>
On June 2, 2014 11:30:20 PM CEST, "Joseph S. Myers" <joseph@codesourcery.com> wrote:
>On Mon, 2 Jun 2014, Florian Weimer wrote:
>
>> On 05/31/2014 08:56 AM, Alan Modra wrote:
>>
>> > > It's fine to change ABI when compiling an old-style function
>> > > definition for which a prototype exists (relative to the
>> > > non-prototype case). It happens on i386, too.
>> >
>> > That might be so, but when compiling the function body you must
>assume
>> > the worst case, whatever that might be, at the call site. For K&R
>> > code, our error was to assume the call was unprototyped (which
>> > paradoxically is the best case) when compiling the function body.
>>
>> Is this really a supported use case? I think I remember tracking
>down a bug
>> which was related to a lack of float -> double promotion because the
>call was
>> prototyped, and the old-style function definition wasn't. This would
>have
>> been on, ugh, SPARC. I think this happened only in certain cases
>(float
>> arguments, probably).
>
>ISO C (right back to C90) requires a prototype in scope if a variadic
>function, or a function whose definition has prototyped argument types
>changed by the default argument promotions (such as float and short),
>is
>called.
>
>It probably makes sense by now to enable
>-Wimplicit-function-declaration
>by default, though that won't catch cases where the file with the
>unprototyped call has a non-prototype declaration such as "int foo();".
There is an old patch of mine warning for this case... Google for -Wunprototyped-calls
Richard.