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++/15837] New: Optimization (of templatized functions?)


Seems to be an optimization bug for some templatized functions that I have
(specifically vbox_blur in the precompiled output pen.ii, which is bzipped as
requested).  It's pretty severe.  

In this case, it crashes in release mode (I think because it is forgetting to
decrement the iterator outpen as specified after the inner loop in vbox_blur
(should be right above all of the test functions at the bottom of the file).  

Another bizarre thing, is if function calls are inserted into the loop (say
print functions for debugging, though it has similar effects for some dummy
functions I've tried), it can change whether or not it crashes and such.

In the end it looks like an optimization bug, where it optimizes its way around
some pretty important operations (pointer operations mostly it seems...).

The program outputs patterns representing the result of the operations (the box
blur is the one that's freaking out). The pattern printed out below the CORRECT
OUTPUT line is what the AFTER BOX BLUR output should look like.  You can also
see the correct output for all of the substeps by compiling it in full debug
mode with no optimizations.  If you need some examples for the function call
thing, just ask, I have plenty (I can send the normal source file with all the
commented out print functions for debugging if need be).

Here's GCC's compiler output:

source='pen.cpp' object='pen.o' libtool=no \
depfile='.deps/pen.Po' tmpdepfile='.deps/pen.TPo' \
depmode=gcc3 /bin/sh ../config/depcomp \
g++ -DHAVE_CONFIG_H -I.. -I../ETL -I.. -I..    -v -save-temps -g -O2 -DNDEBUG
-Wall -c -o pen.o `test -f 'pen.cpp' || echo './'`pen.cpp
Reading specs from /usr/lib/gcc-lib/i686-pc-linux-gnu/3.3.2/specs
Configured with: /var/tmp/portage/gcc-3.3.2-r5/work/gcc-3.3.2/configure
--prefix=/usr --bindir=/usr/i686-pc-linux-gnu/gcc-bin/3.3
--includedir=/usr/lib/gcc-lib/i686-pc-linux-gnu/3.3.2/include
--datadir=/usr/share/gcc-data/i686-pc-linux-gnu/3.3
--mandir=/usr/share/gcc-data/i686-pc-linux-gnu/3.3/man
--infodir=/usr/share/gcc-data/i686-pc-linux-gnu/3.3/info --enable-shared
--host=i686-pc-linux-gnu --target=i686-pc-linux-gnu --with-system-zlib
--enable-languages=c,c++,f77,objc --enable-threads=posix --enable-long-long
--disable-checking --enable-cstdio=stdio --enable-clocale=generic
--enable-__cxa_atexit --enable-version-specific-runtime-libs
--with-gxx-include-dir=/usr/lib/gcc-lib/i686-pc-linux-gnu/3.3.2/include/g++-v3
--with-local-prefix=/usr/local --enable-shared --enable-nls
--without-included-gettext --disable-multilib
Thread model: posix
gcc version 3.3.2 20031218 (Gentoo Linux 3.3.2-r5, propolice-3.3-7)
 /usr/lib/gcc-lib/i686-pc-linux-gnu/3.3.2/cc1plus -E -D__GNUG__=3 -quiet -v -I..
-I../ETL -I.. -I.. -MD pen.d -MF .deps/pen.TPo -MP -MT pen.o -MQ pen.o
-D__GNUC__=3 -D__GNUC_MINOR__=3 -D__GNUC_PATCHLEVEL__=2 -D_GNU_SOURCE
-DHAVE_CONFIG_H -DNDEBUG pen.cpp -Wall -O2 pen.ii
ignoring nonexistent directory
"/usr/lib/gcc-lib/i686-pc-linux-gnu/3.3.2/../../../../i686-pc-linux-gnu/include"
ignoring duplicate directory ".."
ignoring duplicate directory ".."
#include "..." search starts here:
#include <...> search starts here:
 ..
 ../ETL
 /usr/lib/gcc-lib/i686-pc-linux-gnu/3.3.2/include/g++-v3
 /usr/lib/gcc-lib/i686-pc-linux-gnu/3.3.2/include/g++-v3/i686-pc-linux-gnu
 /usr/lib/gcc-lib/i686-pc-linux-gnu/3.3.2/include/g++-v3/backward
 /usr/local/include
 /usr/lib/gcc-lib/i686-pc-linux-gnu/3.3.2/include
 /usr/include
End of search list.
 /usr/lib/gcc-lib/i686-pc-linux-gnu/3.3.2/cc1plus -fpreprocessed pen.ii -quiet
-dumpbase pen.cpp -auxbase-strip pen.o -g -O2 -Wall -version -o pen.s
GNU C++ version 3.3.2 20031218 (Gentoo Linux 3.3.2-r5, propolice-3.3-7)
(i686-pc-linux-gnu)
	compiled by GNU C version 3.3.2 20031218 (Gentoo Linux 3.3.2-r5, propolice-3.3-7).
GGC heuristics: --param ggc-min-expand=51 --param ggc-min-heapsize=40960
 /usr/lib/gcc-lib/i686-pc-linux-gnu/3.3.2/../../../../i686-pc-linux-gnu/bin/as
-V -Qy -o pen.o pen.s
GNU assembler version 2.14.90.0.8 (i686-pc-linux-gnu) using BFD version
2.14.90.0.8 20040114
g++  -v -save-temps -g -O2 -DNDEBUG -Wall   -o pen  pen.o  -lpthread 
Reading specs from /usr/lib/gcc-lib/i686-pc-linux-gnu/3.3.2/specs
Configured with: /var/tmp/portage/gcc-3.3.2-r5/work/gcc-3.3.2/configure
--prefix=/usr --bindir=/usr/i686-pc-linux-gnu/gcc-bin/3.3
--includedir=/usr/lib/gcc-lib/i686-pc-linux-gnu/3.3.2/include
--datadir=/usr/share/gcc-data/i686-pc-linux-gnu/3.3
--mandir=/usr/share/gcc-data/i686-pc-linux-gnu/3.3/man
--infodir=/usr/share/gcc-data/i686-pc-linux-gnu/3.3/info --enable-shared
--host=i686-pc-linux-gnu --target=i686-pc-linux-gnu --with-system-zlib
--enable-languages=c,c++,f77,objc --enable-threads=posix --enable-long-long
--disable-checking --enable-cstdio=stdio --enable-clocale=generic
--enable-__cxa_atexit --enable-version-specific-runtime-libs
--with-gxx-include-dir=/usr/lib/gcc-lib/i686-pc-linux-gnu/3.3.2/include/g++-v3
--with-local-prefix=/usr/local --enable-shared --enable-nls
--without-included-gettext --disable-multilib
Thread model: posix
gcc version 3.3.2 20031218 (Gentoo Linux 3.3.2-r5, propolice-3.3-7)
 /usr/lib/gcc-lib/i686-pc-linux-gnu/3.3.2/collect2 --eh-frame-hdr -m elf_i386
-dynamic-linker /lib/ld-linux.so.2 -o pen
/usr/lib/gcc-lib/i686-pc-linux-gnu/3.3.2/../../../crt1.o
/usr/lib/gcc-lib/i686-pc-linux-gnu/3.3.2/../../../crti.o
/usr/lib/gcc-lib/i686-pc-linux-gnu/3.3.2/crtbegin.o
-L/usr/lib/gcc-lib/i686-pc-linux-gnu/3.3.2
-L/usr/lib/gcc-lib/i686-pc-linux-gnu/3.3.2/../../../../i686-pc-linux-gnu/lib
-L/usr/lib/gcc-lib/i686-pc-linux-gnu/3.3.2/../../.. pen.o -lpthread -lstdc++ -lm
-lgcc_s -lgcc -lc -lgcc_s -lgcc
/usr/lib/gcc-lib/i686-pc-linux-gnu/3.3.2/crtend.o
/usr/lib/gcc-lib/i686-pc-linux-gnu/3.3.2/../../../crtn.o

-- 
           Summary: Optimization (of templatized functions?)
           Product: gcc
           Version: 3.3.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: adruab at voria dot com
                CC: gcc-bugs at gcc dot gnu dot org


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


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