This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
unexpected conversion (feature or bug?)
- To: gcc-bugs at gcc dot gnu dot org
- Subject: unexpected conversion (feature or bug?)
- From: Laszlo Ladanyi <ladanyi at watson dot ibm dot com>
- Date: Mon, 16 Aug 1999 14:39:59 -0400 (EDT)
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