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

Address of 'char' is incorrect.



>Submitter-Id:	net
>Originator:	Stephen Kennedy
>Organization:	Telekinesys Research
>Confidential:	no
>Synopsis:	Address of 'char' is incorrect.
>Severity:	serious
>Priority:	medium
>Category:	c
>Class:		wrong-code
>Release:	3.2.3 20030210 (Debian prerelease) (Debian testing/unstable)
>Environment:
System: Linux stag 2.4.19-686 #1 Thu Aug 8 21:30:09 EST 2002 i686 unknown
Architecture: i686

	
host: i386-pc-linux-gnu
build: i386-pc-linux-gnu
target: i386-pc-linux-gnu
configured with: ../src/configure -v --enable-languages=c,c++,java,f77,proto,pascal,objc,ada --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-gxx-include-dir=/usr/include/c++/3.2 --enable-shared --with-system-zlib --enable-nls --without-included-gettext --enable-__cxa_atexit --enable-clocale=gnu --enable-java-gc=boehm --enable-objc-gc i386-linux
>Description:

	In the example below, '&a' is the address of a local copy of 'a' not of 'a'.
	if the type of 'a' is changed to int, it works as expected.

>How-To-Repeat:

#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);
	printf("b == %i  %x\n", b, &b);
	printf("c == %i  %x\n", c, &c);
}

>Fix:



Reply to: