🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.gcc.bug
Article #1217

bug report

#1217
From: dcb
Date: Fri, 16 Oct 1992 15:08
71 lines
1465 bytes
Hello there,

I have gcc 2.2.2 on sun 4 hardware, with SunOs 4.1.1

Given the following code


#include <stream.h>

static int c = 0;

struct S {
	int loc;
	S() { 
		loc = 0; 
	}
	~S() { 
		++c; 
	}
};

int main() {
	int i;

	for (i = 0; i < 2; ++i) 		// note no {
		for (S j; j.loc < 1; j.loc++) {
			cout << c << "\n";
		}	
	// note no }
	cout << c << "\n";

	return 0;
}

then I get output

0
0
0

But if I change the body of main to 

int main() {
	int i;

	for (i = 0; i < 2; ++i) {	// note {
		for (S j; j.loc < 1; j.loc++) {
			cout << c << "\n";
		}
	}		// note }
	cout << c << "\n";

	return 0;
}

then I get 

0
1
2

This bug happens wether -O is used or not.

If this isn't a bug, then I'd appreciate an ARM page number for the
reason why its different.

Regards

David C Binderman     Dept US/ESI, Bau 60, SEL-Alcatel AG, Lorenz Strasse 10,
D-7000 Stuttgart 40, Germany      dcb@us-es.sel.de   Tel: +49 711 821 3841
Watch out for those dangerous fishy maultaschen !
Technical Details
Message-ID: <9210161308.AA20695@us-es.sel.de>
Path: arc1-ca.pugleaf.net!sparky!uunet!stanford.edu!ames!sun-barr!cs.utexas.edu!uwm.edu!rpi!zaphod.mps.ohio-state.edu!cis.ohio-state.edu!us-es.SEl.DE!dcb

Show Full Headers
Complete Article Headers
Newsgroups: gnu.gcc.bug
Path: arc1-ca.pugleaf.net!sparky!uunet!stanford.edu!ames!sun-barr!cs.utexas.edu!uwm.edu!rpi!zaphod.mps.ohio-state.edu!cis.ohio-state.edu!us-es.SEl.DE!dcb
From: dcb@us-es.SEl.DE
Subject: bug report
Message-ID: <9210161308.AA20695@us-es.sel.de>
Sender: gnulists@ai.mit.edu
Organization: GNUs Not Usenet
Distribution: gnu
Date: Fri, 16 Oct 1992 15:08:03 GMT
Approved: bug-gcc@prep.ai.mit.edu
Lines: 72