[Bug c++/14449] New: long long & unsigned calculation gives wrong result
joerg dot richter at pdv-fs dot de
gcc-bugzilla@gcc.gnu.org
Fri Mar 5 16:14:00 GMT 2004
This program:
-----8<--------------
#include <stdio.h>
int main()
{
unsigned int i = 2147483648u;
long long k = ((long long)i) * 10;
printf( "%lld\n", k );
long long m = i;
m = m * 10;
printf( "%lld\n", m );
}
-----8<--------------
gives following output
-64424509440
21474836480
But I would expect (like on i686-pc-linux-gnu)
21474836480
21474836480
Confirmed with
GCC 3.3.3
GCC 3.2.1
GCC 2.9-aix51-020209
g++ -v prints
Reading specs from /pdv/.tools/pkg/gcc/3.3.3/bin/../lib/gcc-lib/powerpc-ibm-
aix5.1.0.0/3.3.3/specs
Configured with: ../gcc-3.3.3/configure --prefix=/tools/pkg/gcc/3.3.3 --with-
ld=/bin/ld --with-as=/bin/as --enable-languages=c,c++
Thread model: aix
gcc version 3.3.3
--
Summary: long long & unsigned calculation gives wrong result
Product: gcc
Version: 3.3.3
Status: UNCONFIRMED
Severity: critical
Priority: P2
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: joerg dot richter at pdv-fs dot de
CC: gcc-bugs at gcc dot gnu dot org
GCC build triplet: powerpc-ibm-aix5.1.0.0
GCC host triplet: powerpc-ibm-aix5.1.0.0
GCC target triplet: powerpc-ibm-aix5.1.0.0
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14449
More information about the Gcc-bugs
mailing list