The following code when compiled with GCC 4.1.2 gives wrong result
"res = ffffffffffffffff". Code compiled with GCC 4.0.4 or GCC 3.3.3 gives right
result: "res = ffffffff".
In all these cases command line was: "gcc test.c -o test.exe".
Adding optimization options for GCC 4.1.2 do change the output in this example,
but doesn't change anything in real program from which this code was extracted.

Code:
int main()
{
    long long qhat = 1;
    long long res = qhat * 0xffffffffLL;
    printf("res = %llx\n", res);
}

gcc -v output:
Using built-in specs.
Target: i686-pc-cygwin
Configured with: ../gcc-4.1.2/configure --enable-languages=c
--prefix=/usr/local2 : (reconfigured) ../gcc-4.1.2/configur
e --enable-languages=c --prefix=/usr/local2 --enable-libmudflap :
(reconfigured) ../gcc-4.1.2/configure --enable-languag
es=c --prefix=/usr/local2 --enable-libmudflap : (reconfigured)
../gcc-4.1.2/configure --enable-languages=c --prefix=/usr
/local --enable-libmudflap
Thread model: single
gcc version 4.1.2
 /usr/local/libexec/gcc/i686-pc-cygwin/4.1.2/cc1.exe -E -quiet -v
-D__CYGWIN32__ -D__CYGWIN__ -Dunix -D__unix__ -D__unix
 -idirafter /usr/lib/../include/w32api -idirafter
/usr/local/lib/gcc/i686-pc-cygwin/4.1.2/../../../../../include/w32api
test.c -mtune=pentiumpro -fpch-preprocess -o test.i
ignoring nonexistent directory
"/usr/local/lib/gcc/i686-pc-cygwin/4.1.2/../../../../i686-pc-cygwin/include"
ignoring duplicate directory
"/usr/local/lib/gcc/i686-pc-cygwin/4.1.2/../../../../../include/w32api"
#include "..." search starts here:
#include <...> search starts here:
 /usr/local/include
 /usr/local/lib/gcc/i686-pc-cygwin/4.1.2/include
 /usr/include
 /usr/lib/../include/w32api
End of search list.
 /usr/local/libexec/gcc/i686-pc-cygwin/4.1.2/cc1.exe -fpreprocessed test.i
-quiet -dumpbase test.c -mtune=pentiumpro -au
xbase test -version -o test.s
GNU C version 4.1.2 (i686-pc-cygwin)
        compiled by GNU C version 3.3.3 (cygwin special).
GGC heuristics: --param ggc-min-expand=99 --param ggc-min-heapsize=130970
Compiler executable checksum: 4151625f98c48f709a3ef2b42ca0c20b
test.c: In function 'main':
test.c:5: warning: incompatible implicit declaration of built-in function
'printf'
 as -o test.o test.s
 /usr/local/libexec/gcc/i686-pc-cygwin/4.1.2/collect2.exe -Bdynamic
--dll-search-prefix=cyg -o test.exe /lib/crt0.o -L/u
sr/local/lib/gcc/i686-pc-cygwin/4.1.2
-L/usr/local/lib/gcc/i686-pc-cygwin/4.1.2/../../.. test.o -lgcc -lcygwin
-luser32
-lkernel32 -ladvapi32 -lshell32 -lgcc


-- 
           Summary: Incorrect result of multiplication long long by
                    0xFFFFFFFFLL constant.
           Product: gcc
           Version: 4.1.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: vlasenko at bifit dot com dot ua
 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=31679

Reply via email to