From: "Maciej W. Rozycki" <macro@imgtec.com>
To: Matthew Fortune <Matthew.Fortune@imgtec.com>
Cc: Steve Ellcey <Steve.Ellcey@imgtec.com>,
"gcc-patches@gcc.gnu.org" <gcc-patches@gcc.gnu.org>,
"clm@codesourcery.com" <clm@codesourcery.com>
Subject: RE: [Patch, MIPS] Remove definition of TARGET_PROMOTE_PROTOTYPES
Date: Tue, 19 Jan 2016 15:25:00 -0000 [thread overview]
Message-ID: <alpine.DEB.2.00.1601190112040.5958@tp.orcam.me.uk> (raw)
In-Reply-To: <6D39441BF12EF246A7ABCE6654B0235361D03859@LEMAIL01.le.imgtec.org>
On Sat, 12 Dec 2015, Matthew Fortune wrote:
> > > * config/mips/mips.c (mips_promote_function_mode): New function.
> > > (TARGET_PROMOTE_FUNCTION_MODE): Define as above function.
> > > (TARGET_PROMOTE_PROTOTYPES): Remove.
>
> I'm OK with this change on the basis that MIPS has been providing stronger
> guarantees than required by the various standards. I.e. after this change
> MIPS will have undefined behaviour for a mismatch in types between a
> call to an un-prototyped function and its definition:
Indeed this is exactly what the current ISO C language standard mandates
-- if an unprototyped call is made to a function whose definition has been
prototyped and the types of the arguments after promotion are incompatible
with the types of the respective parameters, then behaviour is undefined.
> extern void foo();
>
> void caller(int a)
> {
> foo(a);
> }
>
> --
>
> void foo(short a)
> {
> // the value of 'a' can be out of range of a short because the caller
> // did not get the right type for the argument.
> }
Which is exactly the case with the piece of code you quoted. Behaviour
of this code would be defined if the `a' parameter of `foo' was of the
`int' type. See Section 6.5.2.2 "Function calls", clause 6, for details.
Maciej
prev parent reply other threads:[~2016-01-19 15:25 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-11-10 23:58 Steve Ellcey
2015-12-11 23:04 ` Steve Ellcey
2015-12-12 8:53 ` Matthew Fortune
2016-01-19 15:25 ` Maciej W. Rozycki [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=alpine.DEB.2.00.1601190112040.5958@tp.orcam.me.uk \
--to=macro@imgtec.com \
--cc=Matthew.Fortune@imgtec.com \
--cc=Steve.Ellcey@imgtec.com \
--cc=clm@codesourcery.com \
--cc=gcc-patches@gcc.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).