Re: Ternary operator and memory access
Eric Sosman wrote:
Yes, there can be very very touchy variables, where something that
seems innocuous, like just evaluating their address can cause
side-effects. For example on machines with many segment registers,
just loading up an address into an address register can cause "seg
fault"-like traps. Best example, the x86 in 16-bit protected mode.
Peeking at any segment value that hasnt been explicitly allocated to
your program will trap out. You're typically handed just 4 out of 8192
possible segments, so the odds arent good if the goods are odd.
So compilers, when in that code-generating mode, have to be very
conservative. No loading up of arbitrary addresses, no stuffing extra
info into the top bits of pointers.
Eric Sosman wrote:
Unfortunately, there's a huge loophole: The implementation
gets to define what an "access" is, and the definition may or
may not match the programmer's intent. Most effective uses of
`volatile' thus require some intimacy with the implementation' s
documentation suite.
gets to define what an "access" is, and the definition may or
may not match the programmer's intent. Most effective uses of
`volatile' thus require some intimacy with the implementation' s
documentation suite.
Yes, there can be very very touchy variables, where something that
seems innocuous, like just evaluating their address can cause
side-effects. For example on machines with many segment registers,
just loading up an address into an address register can cause "seg
fault"-like traps. Best example, the x86 in 16-bit protected mode.
Peeking at any segment value that hasnt been explicitly allocated to
your program will trap out. You're typically handed just 4 out of 8192
possible segments, so the odds arent good if the goods are odd.
So compilers, when in that code-generating mode, have to be very
conservative. No loading up of arbitrary addresses, no stuffing extra
info into the top bits of pointers.
Comment