Opened 9 years ago

Closed 7 years ago

#9100 closed Bugs (fixed)

has_*_operator.hpp generates C6334 using VC++

Reported by: ianjirka@… 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 John Maddock, 9 years ago

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.

comment:2 by anonymous, 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 anonymous, 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 John Maddock, 7 years ago

Resolution: fixed
Status: newclosed
Note: See TracTickets for help on using tickets.