Richard E Maine wrote:
> On Sep 22, 2004, at 2:39 PM, Catherine Moroney wrote:
>
>> flt_data(add1(isds))%x => qa_data%wind_data%lo_wind_ns%value
>> int_data(add1(isds))%x => qa_data%wind_data%lo_wind_ns%count
>> flt_data(add1(isds))%x => qa_data%wind_data%lo_wind_ew%value
>> int_data(add1(isds))%x => qa_data%wind_data%lo_wind_ew%count
>
> (where add1 increments its argument).
>
> Ouch. I wouldn't trust it. According to me it is invalid. And I'd bet
> that
> someday you'll run into a compiler that figures it would be a good idea
> to
> optimize the 4 add1 calls by doing it just once. I don't really get much
> pleasure out of saying "I told you so", so I'd recommend against doing
> it.
Unless ADD1 is declared PURE, that "optimization" would be a violation
of the standard even given the disputed interpretation of what can happen
*within* an expression. And, even if ADD1 *was* PURE, that optimization
would violate the standard if either of the variables FLT_DATA or INT_DATA
were in common or MODULEs (since even PURE functions can *depend* on
such global data). If the compiler does this, send it back and warn the
rest of us immediately!
And, if the compiler doesn't execute non-PURE functions, yet it uses
their values, throw it out, get your money back, and warn the rest of
us.
--
J. Giles
"I conclude that there are two ways of constructing a software
design: One way is to make it so simple that there are obviously
no deficiencies and the other way is to make it so complicated
that there are no obvious deficiencies." -- C. A. R. Hoare
|