Re: Optimizations and Language Definitions

Henry Spencer <>
Thu, 22 Sep 88 05:22:31 EDT

          From comp.compilers

Related articles
Optimizations and Language Definitions think!compass! (Dale Worley) (1988-09-13)
Re: Optimizations and Language Definitions (1988-09-20)
Re: Optimizations and Language Definitions (Henry Spencer) (1988-09-22)
| List of all articles for this month |

From: Henry Spencer <>
Date: Thu, 22 Sep 88 05:22:31 EDT

In article <> our moderator writes:
>[No, pragmas aren't supposed to change the semantics of code...

A common misunderstanding. In fact, the last two drafts have not clearly
specified whether they are allowed to or not. Neither interpretation is
self-contradictory. The most common argument against is that one is not
supposed to interpret one paragraph of a standard without considering the
rest, and therefore #pragma is bounded by the rest of the standard. The
counter-argument is that the same reasoning applies in reverse: one cannot
understand the rest of the standard without considering that that one
little paragraph about #pragma may have the power to change it all.
There was some sentiment for resolving this ambiguity, but I don't know
whether anything will be done now (nothing was done in the May draft).

>... since floating point operations are not in general
>associative the "as if" rule would rule out rearranging such operations
>except in the rare case where the compiler can prove that the results are
>the same...

This indeed appears to be the case. The sloppy old C wording about how
the compiler is free to rearrange is pretty much gone, replaced by the
"as if" clause. But the "as if" clause is more restrictive, since it
seldom applies to floating point, and in general doesn't even apply to
integers (although in fact the only real problem with integers is the
occurrence of overflow, and an implementation which ignores overflow
can rearrange integer expressions to its heart's content).

                                                                          Henry Spencer at U of Toronto Zoology

Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.