public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/37922]  New: code generation error
@ 2008-10-26 20:12 rwgk at yahoo dot com
  2008-10-27  0:19 ` [Bug c++/37922] " pinskia at gcc dot gnu dot org
                   ` (26 more replies)
  0 siblings, 27 replies; 28+ messages in thread
From: rwgk at yahoo dot com @ 2008-10-26 20:12 UTC (permalink / raw)
  To: gcc-bugs

Platform:
  Fedora release 8 (Werewolf)
  Linux chevy.lbl.gov 2.6.23.15-137.fc8 #1 SMP Sun Feb 10 17:03:13 EST 2008
x86_64 x86_64 x86_64 GNU/Linux

% g++ -v
Using built-in specs.
Target: x86_64-unknown-linux-gnu
Configured with: /net/chevy/raid1/rwgk/gcc_trunk/configure
--prefix=/net/cci-filer1/vol1/tmp/rwgk/gcc_trunk_141361_fc8_x86_64
--enable-languages=c,c++,fortran
Thread model: posix
gcc version 4.4.0 20081025 (experimental) (GCC) 


Problematic C++ code fragment:

    rot_mx proper_r = r;
    int proper_order = type_;
    if (proper_order < 0) {
      std::cout << "A branch" << std::endl;
      proper_order *= -1;
      proper_r = -proper_r;
    }
    if (proper_order > 1) {
      std::cout << "B branch" << std::endl;
      ...
    }

Compiled with (just to show optimization options; please ignore the rest):

g++ -o cctbx/sgtbx/rot_mx_info.o -c -fno-strict-aliasing -fPIC
-ftemplate-depth-120 -w -DNDEBUG -O3 -ffast-math -fno-associative-math
-ftrapping-math -DBOOST_DISABLE_THREADS -fopenmp -Iinclude
-I/net/chevy/raid1/rwgk/hot/include -I/net/chevy/raid1/rwgk/as_in_cvs/include
"-I/net/chevy/raid1/rwgk/hot/b u f/include" -I/net/chevy/raid1/rwgk/as_in_cvs
-I/net/chevy/raid1/rwgk/hot/boost
/net/chevy/raid1/rwgk/as_in_cvs/cctbx/sgtbx/rot_mx_info.cpp

Given type_ = -2, the print statements should show

A branch
B branch

but only "B branch" is actually shown.

I can work around this problem either by compiling without optimizations, or by
replacing the code above with:

    rot_mx proper_r;
    int proper_order;
    if (type_ < 0) {
      std::cout << "A branch" << std::endl;
      proper_order = -type_;
      proper_r = -r;
    }
    else {
      std::cout << "A else branch" << std::endl;
      proper_order = type_;
      proper_r = r;
    }
    if (proper_order > 1) {
      std::cout << "B branch" << std::endl;
      ...
    }


I tried to reduce the problem, but it turns out to be tricky. The code above is
part of a shared library (.so). Simply moving it into the same translation unit
as the calling code makes the error go away.

Before I spend more time on this, does the problem look familiar? (I.e. could
it be that this bug was reported already?)

I could give you a self-contained but very large reproducer. This would enable
you to inspect the generated code, and maybe give us a clue how to construct a
minimal reproducer.


-- 
           Summary: code generation error
           Product: gcc
           Version: 4.4.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: rwgk at yahoo dot com
 GCC build triplet: x86_64-unknown-linux-gnu
  GCC host triplet: x86_64-unknown-linux-gnu
GCC target triplet: x86_64-unknown-linux-gnu


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


^ permalink raw reply	[flat|nested] 28+ messages in thread

end of thread, other threads:[~2010-05-22 18:26 UTC | newest]

Thread overview: 28+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-10-26 20:12 [Bug c++/37922] New: code generation error rwgk at yahoo dot com
2008-10-27  0:19 ` [Bug c++/37922] " pinskia at gcc dot gnu dot org
2008-10-27  2:19 ` rwgk at yahoo dot com
2008-12-07  7:35 ` rwgk at yahoo dot com
2008-12-07  7:46 ` rwgk at yahoo dot com
2008-12-13 22:10 ` rwgk at yahoo dot com
2008-12-16  0:09 ` [Bug c++/37922] [4.4 Regression] " pinskia at gcc dot gnu dot org
2008-12-16  0:10 ` pinskia at gcc dot gnu dot org
2008-12-16  2:18 ` rwgk at yahoo dot com
2008-12-16  4:03 ` hjl dot tools at gmail dot com
2008-12-16 12:09 ` jakub at gcc dot gnu dot org
2008-12-16 12:49 ` jakub at gcc dot gnu dot org
2008-12-16 13:11 ` jakub at gcc dot gnu dot org
2008-12-16 13:46 ` steven at gcc dot gnu dot org
2008-12-16 15:06 ` jakub at gcc dot gnu dot org
2008-12-16 16:01 ` [Bug c++/37922] [4.3/4.4 " hjl dot tools at gmail dot com
2008-12-16 17:20 ` hjl dot tools at gmail dot com
2008-12-16 18:42 ` hjl dot tools at gmail dot com
2008-12-16 18:45 ` zadeck at naturalbridge dot com
2008-12-17 15:47 ` hjl dot tools at gmail dot com
2008-12-17 19:02 ` rwgk at yahoo dot com
2008-12-18 13:41 ` zadeck at gcc dot gnu dot org
2008-12-18 14:26 ` zadeck at naturalbridge dot com
2008-12-18 14:34 ` hjl dot tools at gmail dot com
2008-12-29 21:34 ` [Bug c++/37922] [4.3 " rguenth at gcc dot gnu dot org
2009-01-24 10:40 ` rguenth at gcc dot gnu dot org
2009-08-04 12:43 ` rguenth at gcc dot gnu dot org
2010-05-22 18:26 ` [Bug rtl-optimization/37922] " rguenth at gcc dot gnu dot org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).