🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c
Article #105

Re: volatile qualifier

#105
From: Art Boyne
Date: Mon, 20 Jul 1992 14:55
17 lines
1060 bytes
One caveat, though, regarding volatile.  The ANSI standard does not
impose any particular implementation on how the compiler handles
volatile.  And one very well-known PC-based compiler has a rather
stupid definition.  Given then code segment:

    #define device_register (*(volatile int*)12345)	/* some address */
    #define MASK 0x400

    if (device_register & MASK)
	    ...

the compiler, realizing that MASK only affects the upper byte of the
16-bit device register, "optimizes" the register access, and does
an 8-bit access.  Now it just happens that the hardware only supports
16-bit access and gives a bus error on 8-bit access....

Art Boyne, boyne@hplvla.lvld.hp.com
Technical Details
Message-ID: <720001@hplvec.LVLD.HP.COM>
Path: arc1-ca.pugleaf.net!sparky!uunet!usc!elroy.jpl.nasa.gov!sdd.hp.com!hpscdc!hplextra!hpfcso!hplvec!boyne
References: <1200@datmuc.UUCP>

Show Full Headers
Complete Article Headers
From: boyne@hplvec.LVLD.HP.COM (Art Boyne)
Date: Mon, 20 Jul 1992 14:55:05 GMT
Subject: Re: volatile qualifier
Message-ID: <720001@hplvec.LVLD.HP.COM>
Organization: Hewlett-Packard Co., Loveland, CO
Path: arc1-ca.pugleaf.net!sparky!uunet!usc!elroy.jpl.nasa.gov!sdd.hp.com!hpscdc!hplextra!hpfcso!hplvec!boyne
Newsgroups: comp.std.c
References: <1200@datmuc.UUCP>
Lines: 17