This is the mail archive of the 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 optimization/11198] New: -O2 -frename-registers generates wrong code


           Summary: -O2 -frename-registers generates wrong code
           Product: gcc
           Version: 3.3
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: optimization
 GCC build triplet: i686-pc-linux-gnu
  GCC host triplet: i686-pc-linux-gnu
GCC target triplet: i686-pc-linux-gnu

The following program

#include <iostream>

#include <boost/numeric/ublas/config.hpp>
#include <boost/numeric/ublas/vector.hpp>
#include <boost/numeric/ublas/matrix.hpp>
#include <boost/numeric/ublas/banded.hpp>
#include <boost/numeric/ublas/io.hpp>

namespace ublas = boost::numeric::ublas;

template<class M>
void initialize_matrix (M &m) {
    int size1 = m.size1 ();
    int size2 = m.size2 ();
    for (int i = 0; i < size1; ++ i)
        for (int j = std::max (i - 1, 0); j < std::min (i + 2, size2); ++ j)
            m (i, j) = i * size1 + j + 1.f;

int main () {
    ublas::banded_matrix<double> m1 (3, 3, 1, 1), m2 (3, 3, 1, 1);
    ublas::banded_adaptor<ublas::banded_matrix<double> > bam1 (m1, 1, 1), bam2 
(m2, 1, 1);
    initialize_matrix (bam1);
    initialize_matrix (bam2);
    bam1.swap (bam2);
    std::cout << "bam1.swap (bam2) = " << bam1 << " " << bam2 << std::endl;


works as intended when compiled with -O2 and core dumps in swap() when 
compiled with -O2 -frename-registers like

g++ -v -save-temps -I/usr/local/lib/boost_dev/boost -fabi-version=0 -DNDEBUG 
-O2 -frename-registers    bug.cpp   -o bug
Reading specs from /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.3/specs
Configured with: ./configure
Thread model: posix
gcc version 3.3
 /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.3/cc1plus -E -D__GNUG__=3 -quiet 
-v -I/usr/local/lib/boost_dev/boost -D__GNUC__=3 -D__GNUC_MINOR__=3 
-D__GNUC_PATCHLEVEL__=0 -D_GNU_SOURCE -DNDEBUG bug.cpp -fabi-version=0 
-frename-registers -O2 bug.ii
ignoring nonexistent directory "NONE/include"
ignoring nonexistent directory "/usr/local/i686-pc-linux-gnu/include"
#include "..." search starts here:
#include <...> search starts here:
End of search list.
 /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.3/cc1plus -fpreprocessed bug.ii 
-quiet -dumpbase bug.cpp -auxbase bug -O2 -version -fabi-version=0 
-frename-registers -o bug.s
GNU C++ version 3.3 (i686-pc-linux-gnu)
	compiled by GNU C version 2.95.3 20010315 (SuSE).
GGC heuristics: --param ggc-min-expand=47 --param ggc-min-heapsize=31945
 as -V -Qy -o bug.o bug.s
GNU assembler version (i486-suse-linux) using BFD version
 /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.3/collect2 -m elf_i386 
-dynamic-linker /lib/ -o bug /usr/lib/crt1.o /usr/lib/crti.o 
-L/usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.3/../../.. bug.o -lstdc++ -lm 
-lgcc_s -lgcc -lc -lgcc_s -lgcc 
/usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.3/crtend.o /usr/lib/crtn.o


The program work correct when compiled with -O2 -frename-registers under GCC 

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