This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Undefined behavior in 950605-1.c
- From: Andreas Schwab <schwab at suse dot de>
- To: Momchil Velikov <velco at fadata dot bg>
- Cc: gcc at gcc dot gnu dot org
- Date: Thu, 25 Jul 2002 11:36:02 +0200
- Subject: Re: Undefined behavior in 950605-1.c
- References: <8765z4e391.fsf@fadata.bg>
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."