M
Michael Press
$cat hunh.c
#include <stdio.h>
int
main(void)
{
long int a = -58;
unsigned long int b = 37;
a %= b;
printf("%ld\n", a);
return 0;
}
$cc -std=c99 -Wall -pedantic -o hunh hunh.c
$./hunh
23
$ cc -v
Using built-in specs.
Target: i686-apple-darwin9
Configured with: /var/tmp/gcc/gcc-5465~16/src/configure --disable-checking -enable-werror --prefix=/usr --mandir=/share/man --enable-languages=c,objc,c++,obj-c++ --program-transform-name=/^[cg][^.-]*$/s/$/-4.0/ --with-gxx-include-dir=/include/c++/4.0.0 --with-slibdir=/usr/lib --build=i686-apple-darwin9 --with-arch=apple --with-tune=generic --host=i686-apple-darwin9 --target=i686-apple-darwin9
Thread model: posix
gcc version 4.0.1 (Apple Inc. build 5465)
---
23 cannot be the right answer because
37 does not divide -58 - 23 = -81.
Is this a bug in the compiler or a problem with the C standard?
#include <stdio.h>
int
main(void)
{
long int a = -58;
unsigned long int b = 37;
a %= b;
printf("%ld\n", a);
return 0;
}
$cc -std=c99 -Wall -pedantic -o hunh hunh.c
$./hunh
23
$ cc -v
Using built-in specs.
Target: i686-apple-darwin9
Configured with: /var/tmp/gcc/gcc-5465~16/src/configure --disable-checking -enable-werror --prefix=/usr --mandir=/share/man --enable-languages=c,objc,c++,obj-c++ --program-transform-name=/^[cg][^.-]*$/s/$/-4.0/ --with-gxx-include-dir=/include/c++/4.0.0 --with-slibdir=/usr/lib --build=i686-apple-darwin9 --with-arch=apple --with-tune=generic --host=i686-apple-darwin9 --target=i686-apple-darwin9
Thread model: posix
gcc version 4.0.1 (Apple Inc. build 5465)
---
23 cannot be the right answer because
37 does not divide -58 - 23 = -81.
Is this a bug in the compiler or a problem with the C standard?