This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: type based aliasing again - meaning of "undefined"


>       behavior, upon use of a  nonportable  or  erroneous  program
>       construct,  of  erroneous data, or of indeterminately valued
>       objects, for which this International  Standard  imposes  no
>       requirement.
>
>It seems to me that that says that a program that does something undefined
>isn't necessarily wrong, just nonportable. Since previous versions of GCC
>apparently behaved consistently when type aliasing requirements were
>violated, why are programs that violate them considered erroneous? Or am I
>misreading the standard?

"imposes no requirement" presumably applies to the *implementation*,
i.e. the compiler, libraries, underlying machine, etc.

Therefore, the apparent consistent behavior which you cite is,
according to the standard, completely irrelevant to the behavior
of an implementation, since the programs that violate the standard
by invoking undefined behavior aren't so much "erroneous" as they
*specifically* grant the implementation the freedom to do whatever
the heck it wants -- including doing the same thing the first 10
million times that undefined behavior is invoked, then something
completely different (like "start World War 3") the next time.

        tq vm, (burley)


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]