Skip to content

Cleanup: Silence Xcode 8.2.1 warnings. #49

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions include/boost/numeric/ublas/detail/matrix_assign.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -978,8 +978,8 @@ namespace detail {
#ifdef _MSC_VER
#pragma warning(pop)
#endif
BOOST_UBLAS_CHECK (m.size1 () == e ().size1 (), bad_size ());
BOOST_UBLAS_CHECK (m.size2 () == e ().size2 (), bad_size ());
BOOST_UBLAS_CHECK (m.size1 () == static_cast<typename M::size_type>(e ().size1 ()), bad_size ());
BOOST_UBLAS_CHECK (m.size2 () == static_cast<typename M::size_type>(e ().size2 ()), bad_size ());
typedef typename M::value_type value_type;
// Sparse type has no numeric constraints to check

Expand All @@ -997,7 +997,9 @@ namespace detail {
while (it2e != it2e_end) {
value_type t (*it2e);
if (t != value_type/*zero*/())
m.insert_element (it2e.index1 (), it2e.index2 (), t);
// Use static_cast to silence Xcode 8.2.1:
// error: implicit conversion loses integer precision: 'size_type' (aka 'unsigned long') to 'size_type' (aka 'int')
m.insert_element (static_cast<typename M::size_type>(it2e.index1 ()), static_cast<typename M::size_type>(it2e.index2 ()), t);
++ it2e;
}
++ it1e;
Expand Down
11 changes: 9 additions & 2 deletions include/boost/numeric/ublas/exception.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#endif

#include <boost/numeric/ublas/detail/config.hpp>
#include <type_traits> // needed for make_unsigned

namespace boost { namespace numeric { namespace ublas {

Expand Down Expand Up @@ -271,8 +272,14 @@ namespace boost { namespace numeric { namespace ublas {
// We better change the signature instead of libcomo ;-)
// const T &same_impl_ex (const T &size1, const T &size2, const char *file, int line) {
T1 same_impl_ex (const T1 &size1, const T2 &size2, const char *file, int line) {
BOOST_UBLAS_CHECK_EX (size1 == size2, file, line, bad_argument ());
return (size1 < size2)?(size1):(size2);
// Use static_cast to silence Xcode 8.2.1:
// error: implicit conversion loses integer precision: 'const unsigned long' to 'int'
typedef typename std::make_unsigned<T1>::type UT1;
typedef typename std::make_unsigned<T2>::type UT2;
UT1 usize1 = static_cast<UT1>(size1);
UT2 usize2 = static_cast<UT2>(size2);
BOOST_UBLAS_CHECK_EX (usize1 == usize2, file, line, bad_argument ());
return static_cast<T1>(usize1 < usize2 ? size1 : size2);
}
template<class T>
BOOST_UBLAS_INLINE
Expand Down
32 changes: 21 additions & 11 deletions include/boost/numeric/ublas/matrix_expression.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2066,11 +2066,13 @@ namespace boost { namespace numeric { namespace ublas {
// Element lookup
BOOST_UBLAS_INLINE
const_iterator1 find1 (int rank, size_type i, size_type j) const {
const_iterator11_type it11 (e1_.find1 (rank, i, j));
const_iterator11_type it11_end (e1_.find1 (rank, size1 (), j));
const_iterator21_type it21 (e2_.find1 (rank, i, j));
// Use static_cast to silence Xcode 8.2.1:
// error: implicit conversion loses integer precision: 'size_type' (aka 'unsigned long') to 'size_type' (aka 'int')
const_iterator11_type it11 (e1_.find1 (rank, static_cast<typename expression1_closure_type::size_type>(i), static_cast<typename expression1_closure_type::size_type>(j)));
const_iterator11_type it11_end (e1_.find1 (rank, static_cast<typename expression1_closure_type::size_type>(size1 ()), static_cast<typename expression1_closure_type::size_type>(j)));
const_iterator21_type it21 (e2_.find1 (rank, static_cast<typename expression2_closure_type::size_type>(i), static_cast<typename expression2_closure_type::size_type>(j)));
const_iterator21_type it21_end (e2_.find1 (rank, size1 (), j));
BOOST_UBLAS_CHECK (rank == 0 || it11 == it11_end || it11.index2 () == j, internal_logic ())
BOOST_UBLAS_CHECK (rank == 0 || it11 == it11_end || static_cast<size_type>(it11.index2 ()) == j, internal_logic ())
BOOST_UBLAS_CHECK (rank == 0 || it21 == it21_end || it21.index2 () == j, internal_logic ())
i = (std::min) (it11 != it11_end ? it11.index1 () : size1 (),
it21 != it21_end ? it21.index1 () : size1 ());
Expand All @@ -2082,11 +2084,13 @@ namespace boost { namespace numeric { namespace ublas {
}
BOOST_UBLAS_INLINE
const_iterator2 find2 (int rank, size_type i, size_type j) const {
const_iterator12_type it12 (e1_.find2 (rank, i, j));
const_iterator12_type it12_end (e1_.find2 (rank, i, size2 ()));
// Use static_cast to silence Xcode 8.2.1:
// error: implicit conversion loses integer precision: 'size_type' (aka 'unsigned long') to 'size_type' (aka 'int')
const_iterator12_type it12 (e1_.find2 (rank, static_cast<typename expression1_closure_type::size_type>(i), static_cast<typename expression1_closure_type::size_type>(j)));
const_iterator12_type it12_end (e1_.find2 (rank, static_cast<typename expression1_closure_type::size_type>(i), static_cast<typename expression1_closure_type::size_type>(size2 ())));
const_iterator22_type it22 (e2_.find2 (rank, i, j));
const_iterator22_type it22_end (e2_.find2 (rank, i, size2 ()));
BOOST_UBLAS_CHECK (rank == 0 || it12 == it12_end || it12.index1 () == i, internal_logic ())
BOOST_UBLAS_CHECK (rank == 0 || it12 == it12_end || static_cast<size_type>(it12.index1 ()) == i, internal_logic ())
BOOST_UBLAS_CHECK (rank == 0 || it22 == it22_end || it22.index1 () == i, internal_logic ())
j = (std::min) (it12 != it12_end ? it12.index2 () : size2 (),
it22 != it22_end ? it22.index2 () : size2 ());
Expand Down Expand Up @@ -2215,7 +2219,9 @@ namespace boost { namespace numeric { namespace ublas {
void increment (sparse_bidirectional_iterator_tag) {
size_type index1 = (*this) ().size1 ();
if (it1_ != it1_end_) {
if (it1_.index1 () <= i_)
// Use static_cast to silence Xcode 8.2.1:
// error: comparison of integers of different signs: 'size_type' (aka 'int') and 'size_type' (aka 'unsigned long')
if (static_cast<size_type>(it1_.index1 ()) <= i_)
++ it1_;
if (it1_ != it1_end_)
index1 = it1_.index1 ();
Expand Down Expand Up @@ -2566,7 +2572,9 @@ namespace boost { namespace numeric { namespace ublas {
void increment (sparse_bidirectional_iterator_tag) {
size_type index1 = (*this) ().size2 ();
if (it1_ != it1_end_) {
if (it1_.index2 () <= j_)
// Use static_cast to silence Xcode 8.2.1:
// error: comparison of integers of different signs: 'size_type' (aka 'int') and 'size_type' (aka 'unsigned long')
if (static_cast<size_type>(it1_.index2 ()) <= j_)
++ it1_;
if (it1_ != it1_end_)
index1 = it1_.index2 ();
Expand Down Expand Up @@ -2624,8 +2632,10 @@ namespace boost { namespace numeric { namespace ublas {
value_type dereference (sparse_bidirectional_iterator_tag) const {
typename E1::value_type t1 = typename E1::value_type/*zero*/();
if (it1_ != it1_end_) {
BOOST_UBLAS_CHECK (it1_.index1 () == i_, internal_logic ());
if (it1_.index2 () == j_)
BOOST_UBLAS_CHECK (static_cast<size_type>(it1_.index1 ()) == i_, internal_logic ());
// Use static_cast to silence Xcode 8.2.1:
// error: comparison of integers of different signs: 'size_type' (aka 'int') and 'const size_type' (aka 'const unsigned long')
if (static_cast<size_type>(it1_.index2 ()) == j_)
t1 = *it1_;
}
typename E2::value_type t2 = typename E2::value_type/*zero*/();
Expand Down
Loading