Skip to contentSkip to conversation

C undefined behavior fix

PATCH [email protected] 2 participants 2 messages Jan 6, 2002

lore
Share & tools
lore
#0 lore raw

<<I see no distinction between read and write in the text of the Ada standard.

Quoted 1 line
Quoted 1 line

The point is that the implementation of a write has, given your quote from the RM, pretty much no choice but to do an exactly "correct" write, but for a read, there is nothing to stop reading MORE than the minimum, the requirement of atomicity is still met. Now of course in your array example, you are exactly right, so you could rig up an array with elements surrounding the one you really want. A bit heavy, but yes, that's a trick that will work.

#1 lore raw
Quoted 1 line · [email protected] wrote:

A bit heavy, but yes, that's a trick that will work.

Well, the whole point of the exercise and discussion is how to be heavy handed with the compiler so that it can't get away with ignoring what the programmer asks even with a good language lawyer :).

If I followed correctly, language lawyer wins in C, but not in Ada (but the developper can loose if the Ada compiler just says the declaration is illegal :).

But even in the case of the compiler reading more (and writing anyway), I think it is the compiler burden to prove that the extra stuff "read" is not observable (in the sense of external
effect) at execution. In a memory-mapped I/O architecture where there is a distinction on external effects between a byte read and a word read (eg: a crash :), the compiler can't get very far IMHO (if it accepts the declaration of course).

Signature · 1 line
Laurent Guerby <[email protected]>