J. David Bryan wrote:
On 19 Oct 2001, at 1:33, Frank Heckenbach wrote:
So, the following program would be allowed to output 0, according to the standard (because i might be mapped to an I/O address that happens to always yield 0)? I strongly doubt it?
Well, you've caught me without my copy of the standard at hand :-), but as I recall, there is a requirement that operations on integers must follow the rules of integer math. I can't check whether assignment is one of those operations listed, but it seems reasonable. So, no, the program you cited wouldn't be a conforming program (pending confirmation from the standard).
I hope so.
But how could the compiler possibly enforce this? Binding to RAM vs. a mapped I/O port (or to ROM) would be done at link time, so must the compiler issue a warning for the "var" statement that variables must be bound to RAM? How else can we disallow such a program?
I think a "processor" according to the standard includes the compiler as well as the linker. Whether in practice a compiler alone (such as GPC) that might be used in conjunction with various linkers could be 100% conforming, is another question (and the answer is probably no, without making some requirements on the linker and forbidding the user of linker scripts etc.).
Yes, but some things (like that the program above should write 42, possibly preceded by a number of spaces) are guaranteed, I think.
Unfortunately, what you and I think has no bearing on the matter. Only what the standard "thinks" is important! ;-) Cite a passage from the standard that states that main program block-level variables may not be bound to external entities, and I will concede your point happily.
I'm just packing my bags and will be gone for the weekend, but I'll look when I'm back ...
Frank