public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* Undefined behavior in 950605-1.c
@ 2002-07-25  7:08 Momchil Velikov
  2002-07-25  8:54 ` Andreas Schwab
  0 siblings, 1 reply; 8+ messages in thread
From: Momchil Velikov @ 2002-07-25  7:08 UTC (permalink / raw)
  To: gcc

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''.

Comments?

~velco

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2002-07-27 22:03 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-07-25  7:08 Undefined behavior in 950605-1.c Momchil Velikov
2002-07-25  8:54 ` Andreas Schwab
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

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).