public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug optimization/12815] New: Code compiled with optimization behaves unexpectedly
@ 2003-10-28 15:43 boris at kolpackov dot net
  2003-10-28 16:14 ` [Bug optimization/12815] [3.3/3.4 Regression] " pinskia at gcc dot gnu dot org
                   ` (11 more replies)
  0 siblings, 12 replies; 13+ messages in thread
From: boris at kolpackov dot net @ 2003-10-28 15:43 UTC (permalink / raw)
  To: gcc-bugs

PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.

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

           Summary: Code compiled with optimization behaves unexpectedly
           Product: gcc
           Version: 3.3.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: optimization
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: boris at kolpackov dot net
                CC: gcc-bugs at gcc dot gnu dot org
 GCC build triplet: i686-gnu-linux
  GCC host triplet: i686-gnu-linux
GCC target triplet: i686-gnu-linux

$ cat >test.cpp
#include <typeinfo>
#include <iostream>

using std::cerr;
using std::endl;

bool
operator== (std::type_info const* pa, std::type_info const& b)
{
  return *pa == b;
}

struct A
{
  virtual
  ~A () {}
};

struct APtr
{
  APtr (A* p)
      : p_ (p)
  {
  }

  A&
  operator* () const
  {
    return *p_;
  }

private:
  A* p_;
};

int
main ()
{
  APtr ap (new A);
  
  for(bool cont__ = true; cont__;)
  {
    cerr << "outer: cont__ " << cont__ << endl;
    
    for(std::type_info const* const exp__ ((&typeid (*ap)));
        cont__;
        cont__ = false)
    {
      cerr << "inner: cont__ " << cont__ << endl;
      
      if(cont__ &&
         exp__ == (typeid (int)) &&
         (cont__ = false, true))
      {
        cerr << "condition" << endl;        
      }
    }
  }
}

$ g++ --version
g++ (GCC) 3.3.2 (Debian)

$ g++ ./test.cpp
$ ./a.out
outer: cont__ 1
inner: cont__ 1
$ g++ -O ./test.cpp
$ ./a.out # will result in infinite loop
outer: cont__ 1
inner: cont__ 1
inner: cont__ 1
inner: cont__ 1
inner: cont__ 1
inner: cont__ 1
inner: cont__ 1
^C
$


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

end of thread, other threads:[~2004-01-14  9:06 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-10-28 15:43 [Bug optimization/12815] New: Code compiled with optimization behaves unexpectedly boris at kolpackov dot net
2003-10-28 16:14 ` [Bug optimization/12815] [3.3/3.4 Regression] " pinskia at gcc dot gnu dot org
2003-10-28 17:20 ` falk at debian dot org
2003-10-28 18:02 ` bangerth at dealii dot org
2003-12-03 14:12 ` [Bug c++/12815] " ebotcazou at gcc dot gnu dot org
2003-12-16 22:45 ` pinskia at gcc dot gnu dot org
2004-01-05 22:13 ` mmitchel at gcc dot gnu dot org
2004-01-06  0:52 ` cvs-commit at gcc dot gnu dot org
2004-01-06  0:52 ` cvs-commit at gcc dot gnu dot org
2004-01-06  0:55 ` [Bug c++/12815] [3.3 " mmitchel at gcc dot gnu dot org
2004-01-06  0:55 ` mmitchel at gcc dot gnu dot org
2004-01-13  0:01 ` cvs-commit at gcc dot gnu dot org
2004-01-14  9:06 ` gdr 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).