Boost logo

Boost :

Subject: Re: [boost] [warnings] Are warnings acceptable artifactsfrom builds?
From: Stewart, Robert (Robert.Stewart_at_[hidden])
Date: 2009-09-09 08:33:36


Michael Fawcett wrote:
> On Tue, Sep 8, 2009 at 7:26 PM, Thomas
> Klimpel<Thomas.Klimpel_at_[hidden]> wrote:
> > Thomas Klimpel wrote:
> >> - It is true that msvc-9 spits out many warnings. However,
> >> it is also
> >> true that "warning C4127: conditional expression is
> >> constant" for a code like
> >> template <typename value_type, typename geometry_type_1,
> >> typename geometry_type_2, int op_type>
> >> void execute_boolean_op(value_type& output_, const
> >> geometry_type_1& lvalue_, const geometry_type_2& rvalue_,
> >> ...
> >> if(op_type < 2)
> >> is nonsense, because op_type is a template parameter. So I have the
> >> impression that the only way to get rid of the msvc warnings is by
> >> disabling the nonsense warnings with appropriate pragmas.
>
> Well, it's right. That's a constant conditional expression. You can
> either ignore the warning or put it in a template specialization which
> would get rid of the warning. Is it defined in the standard that the
> conditional will *always* get optimized away? If it isn't, that seems
> like a reasonable warning.

It seems to me that the compiler could be warning about the constant for one of two good reasons, though it is certainly possible that the warning is bogus. First, it could be alerting you that there's a likely mistake in your code. It is helpful to know that what you thought would be a real conditional turns out to not be so, which permits you to correct your code. Not bad. Second, it could be warning you that the conditional will not be optimized away, thus informing you that your code is less efficient than it could be. The latter may not be accurate; inspecting the assembly output will prove the optimizer's prowess.

It is wise to strive to eliminate all warnings because they cause a second look at the code to be sure it does what's expected and because it is helpful to the library user.

_____
Rob Stewart robert.stewart_at_[hidden]
Software Engineer, Core Software using std::disclaimer;
Susquehanna International Group, LLP http://www.sig.com

IMPORTANT: The information contained in this email and/or its attachments is confidential. If you are not the intended recipient, please notify the sender immediately by reply and immediately delete this message and all its attachments. Any review, use, reproduction, disclosure or dissemination of this message or any attachment by an unintended recipient is strictly prohibited. Neither this message nor any attachment is intended as or should be construed as an offer, solicitation or recommendation to buy or sell any security or other financial instrument. Neither the sender, his or her employer nor any of their respective affiliates makes any warranties as to the completeness or accuracy of any of the information contained herein or that this message or any of its attachments is free of viruses.


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk