This is the mail archive of the gcc-bugs@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]

Re: negating unsigned longs in conditional expressions



  In message <m10P4GB-003wXtC@troja.dachau.marco.de>you write:
  > Hi,
  > 
  > I have tried this small test program on arm32, sparc and i386 (machine
  > specifications are at the end of my posting).
  > 
  > 	#include <stdio.h>
  > 
  > 	int
  > 	main(int argc, char **argv)
  > 	{
  > 		unsigned long ul;
  > 		long l1, l2;
  > 
  > 		if (argc != 2)
  > 			exit(1);
  > 
  > 		ul = atoi(argv[1]);
  > 		l1 = ((long)ul < 0) ? -ul : ul;
  > 
  > 		if ((long)ul < 0)
  > 			l2 = -ul;
  > 		else
  > 			l2 = ul;
  > 
  > 		printf("%08lx %08lx\n", l1, l2);
  > 		exit(0);
  > 	}
  > 
  > In all cases I get
  > 
  > 	$ gcc -o tst tst.c
  > 	$ tst -1000
  > 	fffffc18 000003e8
  > 
  > With our old gcc (2.7.2.1) I get "000003e8 000003e8". Is this a bug, or
  > does my program trigger some unspecified C behaviour?
An FYI -- I tried this with the egcs development sources and I got 
000003e8 000003e8.

jeff


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