Andrew Pinski wrote:
On Fri, 2006-11-10 at 23:05 -0800, Howard Chu wrote:
Daniel Berlin wrote:
We ask the TBAA analyzer "can a store to a short * touch i.
In this case, it says "no", because it's not legal.
If you know the code is not legal, why don't you abort the compilation
with an error code?
The code is legal but undefined at runtime.
Ah... Now we see why people are so easily confused by the overall issue
- ask the question and get conflicting answers on what's legal,
implementation-defined, or undefined.
Back in the gcc 1.x days "#pragma" was implementation-defined, so the
preprocessor would try to execute hack, rogue, and a few other toys
whenever it was encountered in source, whichever got located first.
Eventually someone made the pragmatic decision that gcc should do its
best to actually do something useful when encountering undefined situations.
There was a defect report
to the C standard about undefined code at runtime and rejecting that
code and the C standard committee decided it was not a defect.
http://std.dkuug.dk/JTC1/SC22/WG14/www/docs/dr_109.html
Here is the rational from that Defect report about not rejecting the
undefined behavior:
A conforming implementation must not fail to translate a strictly
conforming program simply because some possible execution of that
program would result in undefined behavior. Because foo might never be
called, the example given must be successfully translated by a
conforming implementation.
What does "successfully translated" mean? Shouldn't "translation" mean
the source code is translated into object code? Shouldn't that mean it
should actually generate code that actually executes, and not get
ignored? Otherwise, "successfully translated" may just as well mean
"invokes nethack, rogue, larn..." at that instant.
--
-- Howard Chu
Chief Architect, Symas Corp. http://www.symas.com
Director, Highland Sun http://highlandsun.com/hyc
OpenLDAP Core Team http://www.openldap.org/project/