Article View: gnu.gcc.help
Article #41392g++ 2.7.2 static objects problem on HP903/HP905 --> HELP needed
From: Gary Hancock
Date: Tue, 26 Mar 1996 00:00
Date: Tue, 26 Mar 1996 00:00
94 lines
2507 bytes
2507 bytes
I'm having a problem getting static objects to run correctly on HP903 or HP905
using g++ 2.7.2. The following code creates three static objects, which
contain a single int Value. The values are printed, incremented and then
printed again.
The output should be and is correct on a Sun413 and Sun55 machine
BumStatic test
test1: a = 0
test1: b = 1
test1: c = 2
test2: a = 1
test2: b = 2
test2: c = 3
But is WRONG on an HP903 and HP905 machine.
BumStatic test
test1: a = 0
test1: b = 0
test1: c = 0
test2: a = 1
test2: b = 1
test2: c = 1
I have rebuilt the gcc/g++ compiler 2.72. and lib++ 2.71, and binutils 2.6
for the HP903.
>>> Any suggestions on what I can do to get the code to work?
>>> For example, are there any known hppa type patches required, or environment
>>> that must exist when building the gcc compiler?
The following is the example code that fails on the HP:
#include <iostream.h>
class BumStatic {
public:
BumStatic() : Value( 0 ) {};
BumStatic( int v ) : Value( v ) {};
~BumStatic() {};
void ValueM( int v ) { Value = v; }
int ValueM() { return Value; }
int operator ++() { ++Value; }
private:
int Value;
}; // end class BumStatic
static BumStatic a;
static BumStatic b( 1 );
static BumStatic c = 2;
main()
{
const char *header = "\nBumStatic test\n";
int va, vb, vc;
cout << header << endl;
va = a.ValueM();
cout << "test1: a = " << va << endl;
vb = b.ValueM();
cout << "test1: b = " << vb << endl;
vc = c.ValueM();
cout << "test1: c = " << vc << endl;
++a;
++b;
++c;
va = a.ValueM();
cout << "test2: a = " << va << endl;
vb = b.ValueM();
cout << "test2: b = " << vb << endl;
vc = c.ValueM();
cout << "test2: c = " << vc << endl;
} // end main
--
Gary W. Hancock email: garyh@chdasic.sps.mot.com
Motorola SPS ASIC APO
Technical Details
Message-ID:
<4j7de1$uee@newsgate.sps.mot.com>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailShow Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 11318c,deeb460a6ce8009a,start X-Google-Attributes: gid11318c,public From: Gary Hancock <garyh> Subject: g++ 2.7.2 static objects problem on HP903/HP905 --> HELP needed Date: 1996/03/26 Message-ID: <4j7de1$uee@newsgate.sps.mot.com> X-Deja-AN: 144112855 content-type: text/plain; charset=us-ascii organization: Motorola Inc. ASIC Test Development, Chandler, AZ x-url: news:gnu.gcc.help mime-version: 1.0 newsgroups: gnu.gcc.help x-mailer: Mozilla 1.12 (X11; U; SunOS 4.1.3_U1 sun4m)