🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.g++.bug
Article #1227

g++ 2.3.1 optimization bug

#1227
From: Jeff Anton
Date: Fri, 20 Nov 1992 18:59
83 lines
3103 bytes
Here is a simple little program and problem.  When compiled with
optimization, the hex manipulator has no effect.
				Jeff Anton
				anton@miro.com
-----------

#include <iostream.h>

void
foo(ostream *o) {
    *o << o->flags() << endl;
    *o << hex << o->flags() << endl;
    *o << dec << o->flags() << endl;
}

void
bar(ostream &o) {
    o << o.flags() << endl;
    o << hex << o.flags() << endl;
    o << dec << o.flags() << endl;
}

int
main(void)
{
    cout << cout.flags() << endl;
    cout << hex << cout.flags() << endl;
    cout << dec << cout.flags() << endl;

    foo(&cout);
    bar(cout);

    cout << cout.flags() << endl;
    cout << hex << cout.flags() << endl;
    cout << dec << cout.flags() << endl;
}



grail:anton[364]: g++ -v test.cc
Reading specs from /usr/local/lib/gcc-lib/sparc-sun-sunos4.1.3/2.3.1/specs
gcc version 2.3.1
 /usr/local/lib/gcc-lib/sparc-sun-sunos4.1.3/2.3.1/cpp -lang-c++ -v -undef -D__GNUC__=2 -D__GNUG__=2 -D__cplusplus -Dsparc -Dsun -Dunix -D__sparc__ -D__sun__ -D__unix__ -D__sparc -D__sun -D__unix test.cc /usr/tmp/cca02430.i
GNU CPP version 2.3.1 (sparc)
 /usr/local/lib/gcc-lib/sparc-sun-sunos4.1.3/2.3.1/cc1plus /usr/tmp/cca02430.i -quiet -dumpbase test.cc -version -o /usr/tmp/cca02430.s
GNU C++ version 2.3.1 (sparc) compiled by GNU C version 2.3.1.
 as -o /usr/tmp/cca024301.o /usr/tmp/cca02430.s
 /usr/local/lib/gcc-lib/sparc-sun-sunos4.1.3/2.3.1/ld -e start -dc -dp /lib/crt0.o -L/usr/local/lib/gcc-lib/sparc-sun-sunos4.1.3/2.3.1 -L/usr/local/lib /usr/tmp/cca024301.o -lg++ -lgcc -lc -lgcc
grail:anton[365]: a.out
536870918
20000006
536870918
84896
14ba0
84896
84896
14ba0
84896
536870918
20000006
536870918
grail:anton[366]: g++ -O2 -v test.cc
Reading specs from /usr/local/lib/gcc-lib/sparc-sun-sunos4.1.3/2.3.1/specs
gcc version 2.3.1
 /usr/local/lib/gcc-lib/sparc-sun-sunos4.1.3/2.3.1/cpp -lang-c++ -v -undef -D__GNUC__=2 -D__GNUG__=2 -D__cplusplus -Dsparc -Dsun -Dunix -D__sparc__ -D__sun__ -D__unix__ -D__sparc -D__sun -D__unix -D__OPTIMIZE__ test.cc /usr/tmp/cca02453.i
GNU CPP version 2.3.1 (sparc)
 /usr/local/lib/gcc-lib/sparc-sun-sunos4.1.3/2.3.1/cc1plus /usr/tmp/cca02453.i -quiet -dumpbase test.cc -O2 -version -o /usr/tmp/cca02453.s
GNU C++ version 2.3.1 (sparc) compiled by GNU C version 2.3.1.
 as -o /usr/tmp/cca024531.o /usr/tmp/cca02453.s
 /usr/local/lib/gcc-lib/sparc-sun-sunos4.1.3/2.3.1/ld -e start -dc -dp /lib/crt0.o -L/usr/local/lib/gcc-lib/sparc-sun-sunos4.1.3/2.3.1 -L/usr/local/lib /usr/tmp/cca024531.o -lg++ -lgcc -lc -lgcc
grail:anton[367]: a.out
536870918
536870918
536870918
84896
84928
84880
84896
84928
84880
536870918
536870918
536870918
Technical Details
Message-ID: <9211201859.AA02492@grail.miro.com>
Path: arc1-ca.pugleaf.net!sparky!uunet!zaphod.mps.ohio-state.edu!cis.ohio-state.edu!miro.COM!anton

Show Full Headers
Complete Article Headers
Newsgroups: gnu.g++.bug
Path: arc1-ca.pugleaf.net!sparky!uunet!zaphod.mps.ohio-state.edu!cis.ohio-state.edu!miro.COM!anton
From: anton@miro.COM (Jeff Anton)
Subject: g++ 2.3.1 optimization bug
Message-ID: <9211201859.AA02492@grail.miro.com>
Sender: gnulists@ai.mit.edu
Organization: Gnus Not Usenet
Distribution: gnu
Date: Fri, 20 Nov 1992 18:59:06 GMT
Approved: bug-g++@prep.ai.mit.edu
Lines: 84