volatile required?
Wm E Davidsen Jr
davidsen at crdos1.crd.ge.COM
Tue Oct 3 01:25:16 AEST 1989
In article <16785 at watdragon.waterloo.edu>, afscian at violet.waterloo.edu (Anthony Scian) writes:
| In article <712 at Aragorn.dde.dk> ct at 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 at 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
More information about the Comp.std.c
mailing list