[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [lmi] assorted warnings & compilation fixes
From: |
Greg Chicares |
Subject: |
Re: [lmi] assorted warnings & compilation fixes |
Date: |
Tue, 29 May 2012 21:36:12 +0000 |
User-agent: |
Mozilla/5.0 (Windows NT 5.1; rv:10.0.2) Gecko/20120216 Thunderbird/10.0.2 |
On 2012-05-25 11:21Z, Vaclav Slavik wrote:
> here are some fixes for warnings (and one compilation error) I recently
> encountered:
I committed the other two, but this one gives me pause:
> (1) This fixes a warning shown by Clang++. I agree with the compiler
> that it's easier on the human reader to use parenthesis here:
>
> diff --git a/value_cast.hpp b/value_cast.hpp
> index 807340d..f26834f 100644
> --- a/value_cast.hpp
> +++ b/value_cast.hpp
> @@ -202,8 +202,8 @@ struct value_cast_choice
> enum
> {
> one_numeric_one_string =
> - boost::is_arithmetic<From>::value && is_string<To >::value
> - || boost::is_arithmetic<To >::value && is_string<From>::value
> + (boost::is_arithmetic<From>::value && is_string<To >::value)
> + || (boost::is_arithmetic<To >::value && is_string<From>::value)
> };
I think of AND as multiplicative, and OR as additive, and I generally
wouldn't parenthesize (a*b)+c . OTOH, '||' and '&&' have equal precedence
in the shell; furthermore, '+' and '*' don't do short-circuit evaluation;
so parentheses here aren't terribly objectionable, either, though I think
the layout guides the reader to the correct interpretation in this case.
I wouldn't mind changing this practice and writing superfluous parentheses,
but I'd rather not introduce inconsistency by changing only one occurrence.
Consider, e.g.:
contains.hpp:
#if defined __BORLANDC__ || defined __COMO_VERSION__ && __COMO_VERSION__ <= 4303
mvc_controller.cpp:
if(checkbox || !control_is_enumerative && !datum)
zero.cpp:
if
( bias_none == bias
|| bias_lower == bias && fb <= 0.0
|| bias_higher == bias && 0.0 <= fb
)
Does Clang++ have a way of detecting similar instances, such as those?
Alternatively, does it have a convenient way of suppressing this warning?
Is Clang++ potentially valuable to us for other reasons?