Created attachment 23157 [details] testcase, run under valgrind to see error I'm seeing the following valgrind errors: > valgrind ./a.out ==4899== Memcheck, a memory error detector ==4899== Copyright (C) 2002-2009, and GNU GPL'd, by Julian Seward et al. ==4899== Using Valgrind-3.5.0 and LibVEX; rerun with -h for copyright info ==4899== Command: ./a.out ==4899== ==4899== Invalid read of size 8 ==4899== at 0x402634: integrate_gf_npbc_ (in /data03/vondele/cp2k_gcc/cp2k/src/a.out) ==4899== by 0x4021B2: main (in /data03/vondele/cp2k_gcc/cp2k/src/a.out) ==4899== Address 0x5b4ee40 is 0 bytes after a block of size 272 alloc'd ==4899== at 0x4C26C3A: malloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so) ==4899== by 0x401A54: main (in /data03/vondele/cp2k_gcc/cp2k/src/a.out) ==4899== for the testcase compiled with > gfortran -O3 -ffast-math test.f90 this happens for current trunk, or more precisely: > gfortran -v -O3 -ffast-math test.f90 Driving: gfortran -v -O3 -ffast-math test.f90 -l gfortran -l m -shared-libgcc Using built-in specs. COLLECT_GCC=gfortran COLLECT_LTO_WRAPPER=/data03/vondele/gnu/gcc_trunk/install/libexec/gcc/x86_64-unknown-linux-gnu/4.6.0/lto-wrapper Target: x86_64-unknown-linux-gnu Configured with: ../gcc/configure --prefix=/data03/vondele/gnu/gcc_trunk/install --enable-languages=c,c++,fortran --disable-multilib --enable-plugins --enable-cloog-backend=isl --with-ppl=/data03/vondele/gnu/ppl-0.11/install --with-cloog=/data03/vondele/gnu/cloog-0.16.1/install/ --with-libelf=/data03/vondele/gnu/libelf-0.8.13/install --enable-gold --enable-checking=release Thread model: posix gcc version 4.6.0 20110128 (experimental) [trunk revision 169358] (GCC) COLLECT_GCC_OPTIONS='-v' '-O3' '-ffast-math' '-shared-libgcc' '-mtune=generic' '-march=x86-64' /data03/vondele/gnu/gcc_trunk/install/libexec/gcc/x86_64-unknown-linux-gnu/4.6.0/f951 test.f90 -quiet -dumpbase test.f90 -mtune=generic -march=x86-64 -auxbase test -O3 -version -ffast-math -fintrinsic-modules-path /data03/vondele/gnu/gcc_trunk/install/lib/gcc/x86_64-unknown-linux-gnu/4.6.0/finclude -o /dev/shm/vondele/cc9gSh7M.s GNU Fortran (GCC) version 4.6.0 20110128 (experimental) [trunk revision 169358] (x86_64-unknown-linux-gnu) compiled by GNU C version 4.6.0 20110128 (experimental) [trunk revision 169358], GMP version 4.3.2, MPFR version 2.4.2, MPC version 0.8.2 GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072 GNU Fortran (GCC) version 4.6.0 20110128 (experimental) [trunk revision 169358] (x86_64-unknown-linux-gnu) compiled by GNU C version 4.6.0 20110128 (experimental) [trunk revision 169358], GMP version 4.3.2, MPFR version 2.4.2, MPC version 0.8.2 GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072 COLLECT_GCC_OPTIONS='-v' '-O3' '-ffast-math' '-shared-libgcc' '-mtune=generic' '-march=x86-64' as --64 -o /dev/shm/vondele/ccpFdwCq.o /dev/shm/vondele/cc9gSh7M.s Reading specs from /data03/vondele/gnu/gcc_trunk/install/lib/gcc/x86_64-unknown-linux-gnu/4.6.0/../../../../lib64/libgfortran.spec rename spec lib to liborig COLLECT_GCC_OPTIONS='-v' '-O3' '-ffast-math' '-shared-libgcc' '-mtune=generic' '-march=x86-64' COMPILER_PATH=/data03/vondele/gnu/gcc_trunk/install/libexec/gcc/x86_64-unknown-linux-gnu/4.6.0/:/data03/vondele/gnu/gcc_trunk/install/libexec/gcc/x86_64-unknown-linux-gnu/4.6.0/:/data03/vondele/gnu/gcc_trunk/install/libexec/gcc/x86_64-unknown-linux-gnu/:/data03/vondele/gnu/gcc_trunk/install/lib/gcc/x86_64-unknown-linux-gnu/4.6.0/:/data03/vondele/gnu/gcc_trunk/install/lib/gcc/x86_64-unknown-linux-gnu/ LIBRARY_PATH=/data03/vondele/gnu/gcc_trunk/install/lib/gcc/x86_64-unknown-linux-gnu/4.6.0/:/data03/vondele/gnu/gcc_trunk/install/lib/gcc/x86_64-unknown-linux-gnu/4.6.0/../../../../lib64/:/lib/../lib64/:/usr/lib/../lib64/:/data03/vondele/gnu/gcc_trunk/install/lib/gcc/x86_64-unknown-linux-gnu/4.6.0/../../../:/lib/:/usr/lib/ COLLECT_GCC_OPTIONS='-v' '-O3' '-ffast-math' '-shared-libgcc' '-mtune=generic' '-march=x86-64' /data03/vondele/gnu/gcc_trunk/install/libexec/gcc/x86_64-unknown-linux-gnu/4.6.0/collect2 --eh-frame-hdr -m elf_x86_64 -dynamic-linker /lib64/ld-linux-x86-64.so.2 /usr/lib/../lib64/crt1.o /usr/lib/../lib64/crti.o /data03/vondele/gnu/gcc_trunk/install/lib/gcc/x86_64-unknown-linux-gnu/4.6.0/crtbegin.o -L/data03/vondele/gnu/gcc_trunk/install/lib/gcc/x86_64-unknown-linux-gnu/4.6.0 -L/data03/vondele/gnu/gcc_trunk/install/lib/gcc/x86_64-unknown-linux-gnu/4.6.0/../../../../lib64 -L/lib/../lib64 -L/usr/lib/../lib64 -L/data03/vondele/gnu/gcc_trunk/install/lib/gcc/x86_64-unknown-linux-gnu/4.6.0/../../.. /dev/shm/vondele/ccpFdwCq.o -lgfortran -lm -lgcc_s -lgcc -lquadmath -lm -lgcc_s -lgcc -lc -lgcc_s -lgcc /data03/vondele/gnu/gcc_trunk/install/lib/gcc/x86_64-unknown-linux-gnu/4.6.0/crtfastmath.o /data03/vondele/gnu/gcc_trunk/install/lib/gcc/x86_64-unknown-linux-gnu/4.6.0/crtend.o /usr/lib/../lib64/crtn.o vondele@pcihopt3:/data03/vondele/cp2k_gcc/cp2k/src> gfortran -O3 -ffast-math test.f90
It is caused by revision 138553: http://gcc.gnu.org/ml/gcc-cvs/2008-08/msg00112.html This may be a dup for PR 44183.
Target piece, if there is one. PR44183 for the vectorizer piece, if there is one.
(In reply to comment #2) > Target piece, if there is one. PR44183 for the vectorizer piece, if there is > one. I'm almost certain that this is a dup of PR44183. As far as I can judge, the result of the calculation is indeed correct. The annoying thing is that this makes valgrind's 'out of bounds checking' kind of useless.
On Mon, 31 Jan 2011, Joost.VandeVondele at pci dot uzh.ch wrote: > http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47522 > > --- Comment #3 from Joost VandeVondele <Joost.VandeVondele at pci dot uzh.ch> 2011-01-31 10:16:24 UTC --- > (In reply to comment #2) > > Target piece, if there is one. PR44183 for the vectorizer piece, if there is > > one. > > I'm almost certain that this is a dup of PR44183. As far as I can judge, the > result of the calculation is indeed correct. > > The annoying thing is that this makes valgrind's 'out of bounds checking' kind > of useless. I think valgrind should simply special-case these kind of out of bounds checks based on the instruction that was used. This is an optimization that is useful (even glibc memcpy routines do that, but they have exception rules in valgrind ...) Richard.
WONTFIX. The transformation is legal. valgrind sucks (maybe report this to them).
(In reply to comment #5) > valgrind sucks (maybe report this to them). I think this is an unnecessary comment (all useful tools have bugs, or features we don't like). The issue has been reported as https://bugs.kde.org/show_bug.cgi?id=264936