Opened 12 years ago

Closed 12 years ago

Last modified 12 years ago

#4669 closed Bugs (worksforme)

Lots of warnings from is_unsigned.hpp

Reported by: Per Ola Ingvarsson <pi@…> Owned by: John Maddock
Milestone: To Be Determined Component: type_traits
Version: Boost 1.43.0 Severity: Problem
Keywords: Cc:

Description

When compiling programs that in some way use is_unsigned_imp, warnings from boost obscure the warnings that I'm interested in (i.e. the ones that I have caused myself). The same problem exists with is_signed_imp.

Environment Info:
FreeBSD 8.1 sparc64
gcc version 4.2.1 20070719 [FreeBSD]

Minimal test program:

#include<boost/type_traits/is_unsigned.hpp>

int isUnsigned() {

return boost::detail::is_unsigned_imp<unsigned int>::value;

}

Result: g++ -I/usr/local/include testa.c -c

/usr/local/include/boost/type_traits/is_unsigned.hpp: In instantiation of 'boost::detail::is_ununsigned_helper<unsigned int>': /usr/local/include/boost/type_traits/is_unsigned.hpp:73: instantiated from 'boost::detail::is_unsigned_imp<unsigned int>' testa.c:5: instantiated from here /usr/local/include/boost/type_traits/is_unsigned.hpp:40: warning: comparison between 'enum boost::detail::is_unsigned_values<unsigned int>::<anonymous>' and 'enum boost::detail::is_unsigned_values<unsigned int>::<anonymous>'

Change History (4)

comment:1 by Per Ola Ingvarsson <skrabban@…>, 12 years ago

Using gcc-4.2.1, is_unsigned_values (via the macro BOOST_STATIC_CONSTANT) becomes:

template <class T>
struct is_unsigned_values
{

typedef typename remove_cv<T>::type no_cv_t;
enum { minus_one = (static_cast<no_cv_t>(-1)) };
enum { zero = (static_cast<no_cv_t>(0)) };

};

Using gcc-4.4.5 (debian), it expands to.

template <class T>
struct is_unsigned_values
{

typedef typename remove_cv<T>::type no_cv_t;
static const no_cv_t minus_one = (static_cast<no_cv_t>(-1));
static const no_cv_t zero = (static_cast<no_cv_t>(0));

};

comment:2 by John Maddock, 12 years ago

Resolution: worksforme
Status: newclosed

I'm unable to reproduce this here: Boost.Config never sets BOOST_NO_INCLASS_MEMBER_INITIALIZATION for any gcc compiler version (which is what would cause BOOST_STATIC_CONSTANT to use enum's rather than a true static constant).

In addition all the type_traits are currently run with -Wall -pedantic -Werror and all the tests are passing even on the BSD platforms that are tested: http://beta.boost.org/development/tests/trunk/developer/type_traits.html

However, some testing reveals that using an enum in this context causes is_unsigned to malfunction anyway, so I'll change the code to always use a static constant.

I'd be interested in knowing why BOOST_NO_INCLASS_MEMBER_INITIALIZATION is being set on this platform/compiler combination - are you using a modified Boost version at all?

comment:3 by John Maddock, 12 years ago

(In [65531]) Change these two traits to always use a static constant and not BOOST_STATIC_CONSTANT - otherwise they don't work! Refs #4669.

comment:4 by Per Ola Ingvarsson <pi@…>, 12 years ago

Non-standard it is. Found out that it is the FreeBSD port that adds the following:

//
// gcc previous to 4.3.x does not implement inclass member initialization
//
#if (__GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ <= 2))
#  define BOOST_NO_INCLASS_MEMBER_INITIALIZATION
#endif

Which is not exactly true, more likely it is a workaround for the problem described in #4381.

Note: See TracTickets for help on using tickets.