[Insight-developers] itkSetClampMacro -- warnings for unsigned int values?

Bill Lorensen bill.lorensen at gmail.com
Mon Jul 18 12:51:28 EDT 2011


Perhaps a new macro:
itkSetClampUnsignedMacro

On Mon, Jul 18, 2011 at 12:43 PM, David Cole <david.cole at kitware.com> wrote:
> On Mon, Jul 18, 2011 at 12:30 PM, Williams, Norman K
> <norman-k-williams at uiowa.edu> wrote:
>> I'm trying the change out, to see what happens. It looks like it does
>> silence that warning, as it's valid to ask if an unsigned value is greater
>> than or equal than zero.
>
> Sure it's valid, but it's still always true. In other words: may as
> well not have an "if" for such an expression... I'm surprised the
> compiler doesn't give a "conditional expression always true" warning.
>
>>
>>
>> I'm more concerned that itkSetClampMacro is used on types where that
>> comparison causes problem. It should not cause a problem with any POD
>> type, but I'm not sure whether its use is limited to POD.
>>
>> On 7/18/11 11:03 AM, "David Cole" <david.cole at kitware.com> wrote:
>>
>>>On Mon, Jul 18, 2011 at 11:43 AM, Williams, Norman K
>>><norman-k-williams at uiowa.edu> wrote:
>>>> This throws compiler warnings:
>>>>
>>>>  itkSetClampMacro(MaxLevel, unsigned int, 0, NumericTraits<unsigned
>>>> int>::max() );
>>>>
>>>> Specifically, it uses the expression _arg < 0, which is always false.
>>>>
>>>>
>>>> This is only seen in the '-Wall -Wextra' world.
>>>>
>>>> Possible solution -- change itkMacro.h and replace
>>>>
>>>> _arg < min
>>>>
>>>> with
>>>>
>>>> !(_arg >= min)
>>>>
>>>
>>>Won't this just change the warning to "this condition is always true"
>>>..... ?
>>>
>>>
>>>> This is a niggling point but eliminating specious and spurious warnings
>>>> will make it easier to see the real warnings.
>>>>
>>>> I imagine that once a compiler optimizes the code in that macro, the end
>>>> result will be nearly the same.
>>>> --
>>>> Kent Williams norman-k-williams at uiowa.edu
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>> ________________________________
>>>> Notice: This UI Health Care e-mail (including attachments) is covered
>>>>by the Electronic Communications Privacy Act, 18 U.S.C. 2510-2521, is
>>>>confidential and may be legally privileged.  If you are not the intended
>>>>recipient, you are hereby notified that any retention, dissemination,
>>>>distribution, or copying of this communication is strictly prohibited.
>>>>Please reply to the sender that you have received the message in error,
>>>>then delete it.  Thank you.
>>>> ________________________________
>>>> _______________________________________________
>>>> Powered by www.kitware.com
>>>>
>>>> Visit other Kitware open-source projects at
>>>> http://www.kitware.com/opensource/opensource.html
>>>>
>>>> Kitware offers ITK Training Courses, for more information visit:
>>>> http://kitware.com/products/protraining.html
>>>>
>>>> Please keep messages on-topic and check the ITK FAQ at:
>>>> http://www.itk.org/Wiki/ITK_FAQ
>>>>
>>>> Follow this link to subscribe/unsubscribe:
>>>> http://www.itk.org/mailman/listinfo/insight-developers
>>>>
>>
>>
>>
>> ________________________________
>> Notice: This UI Health Care e-mail (including attachments) is covered by the Electronic Communications Privacy Act, 18 U.S.C. 2510-2521, is confidential and may be legally privileged.  If you are not the intended recipient, you are hereby notified that any retention, dissemination, distribution, or copying of this communication is strictly prohibited.  Please reply to the sender that you have received the message in error, then delete it.  Thank you.
>> ________________________________
>> _______________________________________________
>> Powered by www.kitware.com
>>
>> Visit other Kitware open-source projects at
>> http://www.kitware.com/opensource/opensource.html
>>
>> Kitware offers ITK Training Courses, for more information visit:
>> http://kitware.com/products/protraining.html
>>
>> Please keep messages on-topic and check the ITK FAQ at:
>> http://www.itk.org/Wiki/ITK_FAQ
>>
>> Follow this link to subscribe/unsubscribe:
>> http://www.itk.org/mailman/listinfo/insight-developers
>>
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Kitware offers ITK Training Courses, for more information visit:
> http://kitware.com/products/protraining.html
>
> Please keep messages on-topic and check the ITK FAQ at:
> http://www.itk.org/Wiki/ITK_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.itk.org/mailman/listinfo/insight-developers
>


More information about the Insight-developers mailing list