Opened 9 years ago
Closed 7 years ago
#9100 closed Bugs (fixed)
has_*_operator.hpp generates C6334 using VC++
Reported by: | Owned by: | John Maddock | |
---|---|---|---|
Milestone: | To Be Determined | Component: | type_traits |
Version: | Boost 1.54.0 | Severity: | Problem |
Keywords: | Cc: |
Description
Warning 2 warning C6334: sizeof operator applied to an expression with an operator might yield unexpected results: Parentheses can be used to disambiguate certain usages. c:\users\ian\dev\tensor\main\code\external\boost\latest\boost\type_traits\detail\has_binary_operator.hpp
This can be fixed by adding an extra set of parentheses around returns_void( ... ). For example: sizeof((returns_void(...))
For example: has_binary_operator.hpp:95 Was:
BOOST_STATIC_CONSTANT( bool, value = (sizeof(::boost::type_traits::yes_type) == sizeof( returns_void( (make<Lhs>() BOOST_TT_TRAIT_OP make<Rhs>(), returns_void_t()) ))) );
With fix:
BOOST_STATIC_CONSTANT( bool, value = (sizeof(::boost::type_traits::yes_type) == sizeof((returns_void( (make<Lhs>() BOOST_TT_TRAIT_OP make<Rhs>(), returns_void_t()) )))) );
I was able to fix has_binary_operator.hpp and has_prefix_operator.hpp this way. I'm sure other metafunctions are affected as well.
Change History (4)
comment:1 by , 9 years ago
comment:2 by , 8 years ago
C6334 is a code analyser warning rather than a regular compiler warning, so you need a version of the compiler that supports the analyser to get it.
comment:3 by , 8 years ago
Understood, can you submit either a patch or a pull request - as I can't reproduce here it is probably safer if you check the proposed fix works?
comment:4 by , 7 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
Finally fixed in https://github.com/boostorg/type_traits/commit/e31d0ab7bdddd08b39342afbf9be3d4ade21d8cf (develop only)
Apologies for taking such a long time to get to this... but do you have a test case?
We compile our tests with -W4 _Werror and they don't show this warning.
Many thanks.