[Bug c++/19603] New: code generation error

rwgk at yahoo dot com gcc-bugzilla@gcc.gnu.org
Mon Jan 24 11:40:00 GMT 2005


gcc CVS mainline, 2005/01/23 12:10 PST
Configured with: /net/legless/scratch1/rwgk/gcc_cvs_head/configure --
prefix=/usr/local_cci/gcc_cvs_head_20050123 --enable-languages=c,c++
Red Hat Enterprise Linux WS release 3 (Taroon)
Boost CVS mainline, 2005/01/06 10:09 PST

The following piece of code works correctly only if CCTBX_GCC4_WORKAROUND is 
defined:

  rt_mx rt_mx::new_denominators(int r_den, int t_den) const
  {
    rt_mx result(*this);
#ifndef CCTBX_GCC4_WORKAROUND
    if (r_den) result.r_ = result.r_.new_denominator(r_den);
#else
    if (r_den) {
      rot_mx r = result.r_.new_denominator(r_den);
      result.r_ = r;
    }     
#endif
    if (t_den) result.t_ = result.t_.new_denominator(t_den);
    return result;
  }   

A reproducer is available here:

http://cci.lbl.gov/~rwgk/bugs/gcc_cvs_head_20050123/gcc4_debug.tar.gz

To build:

gunzip -c gcc4_debug.tar.gz | tar xf -
cd gcc4_debug
make

Expected output:

g++ -fPIC -ftemplate-depth-120 -w -DBOOST_DISABLE_THREADS -DNDEBUG -O3 -ffast-
math -I. -c gcc4_debug.cpp
g++ -fPIC -ftemplate-depth-120 -w -DBOOST_DISABLE_THREADS -DNDEBUG -O3 -ffast-
math -I. -c cctbx.cpp -o cctbx_normal.o
g++ -o normal gcc4_debug.o cctbx_normal.o
g++ -fPIC -ftemplate-depth-120 -w -DBOOST_DISABLE_THREADS -DNDEBUG -O3 -ffast-
math -I. -DCCTBX_GCC4_WORKAROUND -c cctbx.cpp -o cctbx_hacked.o
g++ -o hacked gcc4_debug.o cctbx_hacked.o

This will only take a few seconds to build the commands "normal" and "hacked". 
The expected output is:

./normal

y,z,x
x,y,z

./hacked

y,z,x
y,z,x

The output of ./normal is wrong, the output of ./hacked is correct. The only 
difference is the CCTBX_GCC4_WORKAROUND.

The same code works fine (without the workaround) with gcc 3.2.3 and many other 
compilers.

I will try to attach the reproducer if possible. It still is 877kB in size, 
starting from 15+MB, mainly because of the Boost headers. I spent several hours 
stripping it down to this size. I hope you have tools to reduce the rest much 
faster.

-- 
           Summary: code generation error
           Product: gcc
           Version: 4.0.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: rwgk at yahoo dot com
                CC: gcc-bugs at gcc dot gnu dot org
 GCC build triplet: i686-pc-linux-gnu
  GCC host triplet: i686-pc-linux-gnu
GCC target triplet: i686-pc-linux-gnu


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



More information about the Gcc-bugs mailing list