From: Yuval Ronen (ronen_yuval_at_[hidden])
Date: 2006-06-30 01:03:00
> On 6/29/06, Yuval Ronen <ronen_yuval_at_[hidden]> wrote:
>> This warning is not so bad, IMO. It tells you that you are trying
>> evaluate a compile-time constant in run-time, and that's wasting CPU
>> cycles. The runtime 'if' can be substituted by a compile-time
>> This will prevent the compiler from generating the runtime comparison.
>> Sure this is a small piece of code we are trying to optimize, and a good
>> optimizing compiler would remove it anyway, but if we can write more
>> efficient code without relying on a compiler optimization that might or
>> might not be there, isn't it better?
> Surely if a compiler is smart enough to know that a conditional is
> constant then it should be able to get rid of the test-and-branch
You're probably right, but Microsoft, perhaps unintentionally, produced
a warning that helps us generate more portable code - code that doesn't
rely on optimizations present on specific compilers. The question is "do
we want to rely on such optimizations when writing portable code?" I'm
not saying the answer is "No", or even that there is an absolute answer;
I just raised the question...
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk