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]

unexpected conversion (feature or bug?)


Hello,

I think I've found something in the current gcc that is an unexpected
behaviour. (It might be a feature :-). Here are the facts:

1) gcc version (stock gcc package from the debian/gnu linux potato
   distribution as of 08/16/99)
ladanyi-tp:/usr/doc/gcc> gcc -v
Reading specs from /usr/lib/gcc-lib/i386-linux/2.95.1/specs
gcc version 2.95.1 19990809 (prerelease)

2) source code of `check.c'
#include <stdio.h>
int
main()
{
   int i = -1;
   int j = 0;
   j = i/4;
   printf("%i ", j);
   j = i/sizeof(int);
   printf("%i\n", j);
}

3) compile:
gcc check.c

3) output:
0 1073741823

I expected `0 0' as the output. Apparently gcc converts both x and y in an x/y
expression to size_t if y is size_t. Conversion is obviously necessary, and I
think it'd make more sense to convert the size_t into an int. Let me know what
do you think.

Thanks,
--Laci Ladanyi
ladanyi@watson.ibm.com


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