--- Thomas Hruska wrote:
> Try compiling your code as C++ and see if there
> is a difference. C++ compilers tend to generate a lot more warnings as
> the language is, generally-speaking, more strict.
[EMAIL PROTECTED] ~/programming/c++/problem
$ ls -la
total 10
drwxr-xr-x+ 2 root None 4096 Nov 27 22:47 .
drwxr-xr-x+ 11 root None 4096 Nov 27 22:35 ..
-rw-r--r-- 1 root None 69 Nov 27 22:37 Makefile
-rw-r--r-- 1 root None 261 Nov 27 22:46 problem.cpp
[EMAIL PROTECTED] ~/programming/c++/problem
$ cat problem.cpp
#include <climits>
#include <iostream>
using namespace std;
int main (void) {
unsigned short int a;
unsigned long long int b, c;
a = USHRT_MAX;
b = (a*a);
c = ((unsigned int)a*(unsigned int)a);
cout << "Why " << hex << b << " != " << c << " ?\n";
return 0;
}
[EMAIL PROTECTED] ~/programming/c++/problem
$ cat Makefile
problem : problem.cpp
g++ -Wall -Wconversion problem.cpp -o problem
[EMAIL PROTECTED] ~/programming/c++/problem
$ make
g++ -Wall -Wconversion problem.cpp -o problem
[EMAIL PROTECTED] ~/programming/c++/problem
$ ./problem.exe
Why fffffffffffe0001 != fffe0001 ?