[Exceptional C++ Style] Exceptional C++ Style - Item 24: Cons tant Optimization
James Dennett
jdennett at acm.org
Mon Jan 24 11:02:01 EST 2005
On Monday, January 24, 2005, at 05:47 AM, David Nash wrote:
>>
>> Except that would invoke the dreaded Undefined Behaviour.
>>
>> See 7.1.5.1/4
>>
>> Ric
>
> Ah, right. I stand corrected. I did test it but didn't think of
> checking the standard.
>
There are cases where testing will show unexpected behaviour
for this case -- in some situations the compiler will optimize the
const value and replace it at compile times, in other situations it
might use the "new value", so giving inconsistent output.
-- James
More information about the Effective-cpp
mailing list