This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Undefined behavior in 950605-1.c


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]