Article View: comp.std.c
Article #634Re: volatile required?
From: Anthony Scian
Date: Fri, 29 Sep 1989 14:30
Date: Fri, 29 Sep 1989 14:30
21 lines
1165 bytes
1165 bytes
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.
--
Anthony
//// Anthony Scian afscian@violet.uwaterloo.ca afscian@violet.waterloo.edu ////
"I can't believe the news today, I can't close my eyes and make it go away" -U2
Technical Details
Message-ID:
<16785@watdragon.waterloo.edu>Path:
arc1-ca.pugleaf.net!utzoo!attcan!utgpu!watmath!watdragon!violet!afscianReferences:
<712@Aragorn.dde.dk>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!attcan!utgpu!watmath!watdragon!violet!afscian From: afscian@violet.waterloo.edu (Anthony Scian) Newsgroups: comp.std.c Subject: Re: volatile required? Message-ID: <16785@watdragon.waterloo.edu> Date: 29 Sep 89 14:30:35 GMT References: <712@Aragorn.dde.dk> Sender: daemon@watdragon.waterloo.edu Reply-To: afscian@violet.waterloo.edu (Anthony Scian) Organization: U. of Waterloo, Ontario Lines: 21