It is a beginer bug, but it would be nice to get a warning in: #include <stdio.h> unsigned val1 = 0x10000000, val2 = 0x100; int main(int argc, char **argv) { unsigned long long val3 = val1 * val2; printf ("val1 = 0x%X, val2 = 0x%X, val3 = 0x%llX, val1*val2 = 0x%llX\n", val1, val2, val3, (unsigned long long)(val1*val2)); }
Obviously the line printed is: val1 = 0x10000000, val2 = 0x100, val3 = 0x0, val1*val2 = 0x0 (compiled with "gcc -w -Wall -O2 tmp.c" you get no warning) Got bitten yesterday by gcc-4.4.3, reproduced today on gcc version 4.1.2. -- Summary: Warning "u64 = u32 * u32;" - i.e. not casting one u32 to u64 Product: gcc Version: 4.4.3 Status: UNCONFIRMED Severity: enhancement Priority: P3 Component: c AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: etienne_lorrain at yahoo dot fr GCC build triplet: i686-pc-cygwin GCC host triplet: i686-pc-cygwin GCC target triplet: i686-pc-cygwin http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42935