public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
From: Andreas Schwab <schwab@suse.de>
To: Momchil Velikov <velco@fadata.bg>
Cc: gcc@gcc.gnu.org
Subject: Re: Undefined behavior in 950605-1.c
Date: Thu, 25 Jul 2002 08:54:00 -0000	[thread overview]
Message-ID: <jen0sg87zx.fsf@sykes.suse.de> (raw)
In-Reply-To: <8765z4e391.fsf@fadata.bg> (Momchil Velikov's message of "25 Jul 2002 09:22:02 +0300")

Momchil Velikov <velco@fadata.bg> writes:

|> IMHO, gcc.c-torture/execute/950605-1.c (pasted below) provokes
|> undefined behavior according to ISO 9899:1999 6.5.2.2 [#6]
|> 
|>        ... If the function is defined with a type that does not
|>        include a prototype, and the types of the arguments after
|>        promotion are not compatible with those of the parameters after
|>        promotion, the behavior is undefined, except for the following
|>        cases:
|> 
|>          -- one promoted type is a signed integer type, the other
|>             promoted type is the corresponding unsigned integer type,
|>             and the value is representable in both types;
|> 
|> f (c)
|>     unsigned char c;
|> {
|>   if (c != 0xFF)
|>     abort ();
|> }
|> 
|> main ()
|> {
|>   f (-1);
|>   exit (0);
|> }
|> 
|> IOW, the value -1 is not representable in the promoted type of the
|> formal parameter of ``f''.

The promoted type of the formal parameter of f is either int or unsigned
int, and -1 is representable in both types.

Andreas.

-- 
Andreas Schwab, SuSE Labs, schwab@suse.de
SuSE Linux AG, Deutschherrnstr. 15-19, D-90429 Nürnberg
Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."

  reply	other threads:[~2002-07-25  9:36 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-07-25  7:08 Momchil Velikov
2002-07-25  8:54 ` Andreas Schwab [this message]
2002-07-25  9:04   ` Momchil Velikov
     [not found]     ` <20020725102412.GV26054@bubble.sa.bigpond.net.au>
2002-07-25 10:56       ` Momchil Velikov
2002-07-25 11:24         ` Andreas Schwab
2002-07-25 13:25         ` Richard Henderson
2002-07-26 14:47           ` Richard Earnshaw
2002-07-28  0:08             ` Richard Henderson

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=jen0sg87zx.fsf@sykes.suse.de \
    --to=schwab@suse.de \
    --cc=gcc@gcc.gnu.org \
    --cc=velco@fadata.bg \
    /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).