Article View: comp.std.c
Article #649Re: volatile required?
From: Wm E Davidsen Jr
Date: Mon, 02 Oct 1989 15:25
Date: Mon, 02 Oct 1989 15:25
32 lines
1830 bytes
1830 bytes
In article <16785@watdragon.waterloo.edu>, afscian@violet.waterloo.edu (Anthony Scian) writes:
| In article <712@Aragorn.dde.dk> ct@dde.dk (Claus Tondering) writes:
| >Consider the following program:
| >
| > main()
| > {
| > int p=3, *q=&p;
| >
| > *q=4;
| > printf("%d\n",p);
| > }
| >
| >Is it acceptable that this program prints 3 instead of 4?
|
| NO. This is a convenient type of oversight that allows so called
| "optimizing compilers" like Turbo C and Microsoft C to squeeze
| out extra performance from benchmarks. Too bad if production code
| doesn't run with the optimizer turned on. True optimizing
| compilers (WATCOM C,GNU CC) don't resort to "tricks" like this.
You are correct that 3 is not acceptable, but what in the world has
the original topic to do with the attack on MSC and TC? I don't know
about TC, but I tried MSC on the program as posted and it doesn't have
any such problem.
I do not have easy access to old versions of MSC or TC, so I can speak
only to the receent (4.85, 5.0, 5.1) MSC. Those version correctly print 4.
--
bill davidsen (davidsen@crdos1.crd.GE.COM -or- uunet!crdgw1!crdos1!davidsen)
"The world is filled with fools. They blindly follow their so-called
'reason' in the face of the church and common sense. Any fool can see
that the world is flat!" - anon
Technical Details
Message-ID:
<684@crdos1.crd.ge.COM>Path:
arc1-ca.pugleaf.net!utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!uwm.edu!rpi!crdgw1!crdos1!davidsenReferences:
<712@Aragorn.dde.dk> <16785@watdragon.waterloo.edu>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!uwm.edu!rpi!crdgw1!crdos1!davidsen From: davidsen@crdos1.crd.ge.COM (Wm E Davidsen Jr) Newsgroups: comp.std.c Subject: Re: volatile required? Summary: Answer not on question topic Message-ID: <684@crdos1.crd.ge.COM> Date: 2 Oct 89 15:25:16 GMT References: <712@Aragorn.dde.dk> <16785@watdragon.waterloo.edu> Reply-To: davidsen@crdos1.UUCP (bill davidsen) Organization: GE Corp R&D Center Lines: 32