This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c/11307] New: Random printf values under different optimization levels.


PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11307

           Summary: Random printf values under different optimization
                    levels.
           Product: gcc
           Version: 3.3
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: paudley at compbio dot dundee dot ac dot uk
                CC: gcc-bugs at gcc dot gnu dot org
 GCC build triplet: i386-linux
  GCC host triplet: i386-linux
GCC target triplet: i386-linux

The following code:

------------8<----------------
main() {
  int n = 10;
  double s = 5;
  printf( "int n = %i\n", n );
  printf( "double s = %f\n", s );
  printf( "n, s: %f, %f\n", n, s );
  printf( "s, n: %f, %f\n", s, n );
}
---------->8------------------

Generates different output under -O0 and -O1 or higher.

O0:
ant:/tmp$ gcc -O0 yak.c; ./a.out
int n = 10
double s = 5.000000
       n, s:   0.000000, 223404472442755743744.000000
       s, n:   5.000000, 223404437215434309632.000000

O1:
ant:/tmp$ gcc -O1 yak.c; ./a.out
int n = 10
double s = 5.000000
       n, s:   0.000000, 0.000000
       s, n:   5.000000, 223404437215434309632.000000

This case was distill from a larger file which is avaible if you'd like it.

Output of gcc -v
ant:/tmp$ gcc -v -save-temps yak.c
Reading specs from /usr/lib/gcc-lib/i386-linux/3.3/specs
Configured with: ../src/configure -v
--enable-languages=c,c++,java,f77,pascal,objc,ada,treelang --prefix=/usr
--mandir=/usr/share/man --infodir=/usr/share/info
--with-gxx-include-dir=/usr/include/c++/3.3 --enable-shared --with-system-zlib
--enable-nls --without-included-gettext --enable-__cxa_atexit
--enable-clocale=gnu --enable-debug --enable-java-gc=boehm
--enable-java-awt=xlib --enable-objc-gc i386-linux
Thread model: posix
gcc version 3.3 (Debian)
 /usr/lib/gcc-lib/i386-linux/3.3/cc1 -E -quiet -v -D__GNUC__=3
-D__GNUC_MINOR__=3 -D__GNUC_PATCHLEVEL__=0 yak.c yak.i
ignoring nonexistent directory "/usr/i386-linux/include"
#include "..." search starts here:
#include <...> search starts here:
 /homes/paudley/system/stow/include
 /usr/local/include
 /usr/lib/gcc-lib/i386-linux/3.3/include
 /usr/include
End of search list.
 /usr/lib/gcc-lib/i386-linux/3.3/cc1 -fpreprocessed yak.i -quiet -dumpbase yak.c
-auxbase yak -version -o yak.s
GNU C version 3.3 (Debian) (i386-linux)
        compiled by GNU C version 3.3 (Debian).
GGC heuristics: --param ggc-min-expand=98 --param ggc-min-heapsize=128862
 as -V -Qy -o yak.o yak.s
GNU assembler version 2.14.90.0.4 (i386-linux) using BFD version 2.14.90.0.4
20030523 Debian GNU/Linux
 /usr/lib/gcc-lib/i386-linux/3.3/collect2 --eh-frame-hdr -m elf_i386
-dynamic-linker /lib/ld-linux.so.2
/usr/lib/gcc-lib/i386-linux/3.3/../../../crt1.o
/usr/lib/gcc-lib/i386-linux/3.3/../../../crti.o
/usr/lib/gcc-lib/i386-linux/3.3/crtbegin.o -L/homes/paudley/system/stow/lib
-L/usr/lib/gcc-lib/i386-linux/3.3 -L/usr/lib/gcc-lib/i386-linux/3.3/../../..
yak.o -lgcc -lgcc_eh -lc -lgcc -lgcc_eh /usr/lib/gcc-lib/i386-linux/3.3/crtend.o
/usr/lib/gcc-lib/i386-linux/3.3/../../../crtn.o


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]