[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: c/9762: Address of 'char' is incorrect.

stephen.kennedy@havok.com writes:

|> #define TA char
|> #define TB int
|> #define TC int
|> void foobar(TA a, TB b, TC c);
|> int main()
|> {
|> 	foobar(1,2,3);
|> 	return 0;
|> }
|> void foobar(TA a, TB b, TC c)
|> {
|> 	printf("a == %i  claims %x\n", a, &a);
|> 	printf("a == %i  really %x\n", (&b)[-1], (&b)-1);

There is nothing in the C standard that requires that (char*)(&b-1) == &a.
They are distinct objects, thus not comparable, and &b-1 by itself is
already invalid.


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 to: