public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/33249]  New: -O3 and -O2 give wrong results with gcc 4.1.2 on solaris sparc
@ 2007-08-30 14:24 satyaakam at yahoo dot co dot in
  2007-08-30 14:43 ` [Bug rtl-optimization/33249] " rguenth at gcc dot gnu dot org
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: satyaakam at yahoo dot co dot in @ 2007-08-30 14:24 UTC (permalink / raw)
  To: gcc-bugs

The following code gives different results with -O3 (or -O2) and no
optimization.The -O3 output is wrong. 

try:

$g++ -O3 test.cpp

$cat test.cpp

#include <iostream>

class foo
{
  int _type;
public:
  foo( int t ) : _type(t) {};
  bool is_1()   { return _type == 1; }
  bool is_23()  { return _type == 2 || _type == 3; }
};

void testit( foo& e1, foo& e2 )
{
  if ( e1.is_1() && e2.is_1() )
    std::cout << "If - 1.1\n";
  else if ( e1.is_23() && e2.is_23() )
    std::cout << "If - 23.23\n";
  else if ( e1.is_1() && e2.is_23() )
    std::cout << "If - 1.23\n";
  else if ( e1.is_23() && e2.is_1() )
    std::cout << "If - 23.1\n";
  else
    std::cout << "If - bad\n";
}

int main()
{
  for ( int i = 1; i < 4; ++i )
    for ( int j = 1; j < 4; ++j )
    {
      foo e1(i);
      foo e2(j);

      testit( e1, e2 );
    }

  return 0;
}


result with -O3 : 
$./a.out
If - 1.1
If - 1.23
If - 1.23
If - 23.1
If - 23.23
If - 23.23
If - bad
If - 23.23
If - 23.23

result without optimization :
$./a.out
If - 1.1
If - 1.23
If - 1.23
If - 23.1
If - 23.23
If - 23.23
If - 23.1
If - 23.23
If - 23.23

satya


-- 
           Summary: -O3 and -O2 give wrong results with gcc 4.1.2 on solaris
                    sparc
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: satyaakam at yahoo dot co dot in


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


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

* [Bug rtl-optimization/33249] -O3 and -O2 give wrong results with gcc 4.1.2 on solaris sparc
  2007-08-30 14:24 [Bug c++/33249] New: -O3 and -O2 give wrong results with gcc 4.1.2 on solaris sparc satyaakam at yahoo dot co dot in
@ 2007-08-30 14:43 ` rguenth at gcc dot gnu dot org
  2007-09-01 13:26 ` satyaakam at yahoo dot co dot in
  2008-11-30 12:07 ` [Bug rtl-optimization/33249] [4.1 regression] -O3 and -O2 give wrong results ebotcazou at gcc dot gnu dot org
  2 siblings, 0 replies; 4+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2007-08-30 14:43 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from rguenth at gcc dot gnu dot org  2007-08-30 14:43 -------
This works for me on x86_64 and i686.  Possibly a rtl-optimization or target
bug.
As there were loop fixes after 4.1.2 went out can you try with the trunk of
the gcc-4_1-branch or give the exact version of your compiler (gcc --version
will tell)?


-- 

rguenth at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
          Component|c++                         |rtl-optimization
 GCC target triplet|                            |sparc-sun-solaris
            Version|unknown                     |4.1.2


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


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

* [Bug rtl-optimization/33249] -O3 and -O2 give wrong results with gcc 4.1.2 on solaris sparc
  2007-08-30 14:24 [Bug c++/33249] New: -O3 and -O2 give wrong results with gcc 4.1.2 on solaris sparc satyaakam at yahoo dot co dot in
  2007-08-30 14:43 ` [Bug rtl-optimization/33249] " rguenth at gcc dot gnu dot org
@ 2007-09-01 13:26 ` satyaakam at yahoo dot co dot in
  2008-11-30 12:07 ` [Bug rtl-optimization/33249] [4.1 regression] -O3 and -O2 give wrong results ebotcazou at gcc dot gnu dot org
  2 siblings, 0 replies; 4+ messages in thread
From: satyaakam at yahoo dot co dot in @ 2007-09-01 13:26 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from satyaakam at yahoo dot co dot in  2007-09-01 13:26 -------
it is gcc 4.1.2 the base release.

Satya


-- 


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


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

* [Bug rtl-optimization/33249] [4.1 regression] -O3 and -O2 give wrong results
  2007-08-30 14:24 [Bug c++/33249] New: -O3 and -O2 give wrong results with gcc 4.1.2 on solaris sparc satyaakam at yahoo dot co dot in
  2007-08-30 14:43 ` [Bug rtl-optimization/33249] " rguenth at gcc dot gnu dot org
  2007-09-01 13:26 ` satyaakam at yahoo dot co dot in
@ 2008-11-30 12:07 ` ebotcazou at gcc dot gnu dot org
  2 siblings, 0 replies; 4+ messages in thread
From: ebotcazou at gcc dot gnu dot org @ 2008-11-30 12:07 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from ebotcazou at gcc dot gnu dot org  2008-11-30 12:06 -------
Works fine with GCC 4.2.x and later.


-- 

ebotcazou at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
 GCC target triplet|sparc-sun-solaris           |sparc-sun-solaris2.*
           Keywords|                            |wrong-code
      Known to work|                            |3.4.4 4.2.4 4.3.3 4.4.0
         Resolution|                            |FIXED
            Summary|-O3 and -O2 give wrong      |[4.1 regression] -O3 and -O2
                   |results with gcc 4.1.2 on   |give wrong results
                   |solaris sparc               |
   Target Milestone|---                         |4.2.0


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


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

end of thread, other threads:[~2008-11-30 12:07 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-08-30 14:24 [Bug c++/33249] New: -O3 and -O2 give wrong results with gcc 4.1.2 on solaris sparc satyaakam at yahoo dot co dot in
2007-08-30 14:43 ` [Bug rtl-optimization/33249] " rguenth at gcc dot gnu dot org
2007-09-01 13:26 ` satyaakam at yahoo dot co dot in
2008-11-30 12:07 ` [Bug rtl-optimization/33249] [4.1 regression] -O3 and -O2 give wrong results ebotcazou 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).