Opened 10 years ago

Closed 5 years ago

Last modified 5 years ago

#7270 closed Bugs (fixed)

C++11 narrowing problem in gil

Reported by: Jim Bosch Owned by: Mateusz Loskot
Milestone: Boost 1.68.0 Component: gil USE GITHUB
Version: Boost 1.63.0 Severity: Problem
Keywords: c++11 Cc: mateusz@…

Description

Compiling against Boost.Gil on Clang with C++11 extensions enabled, I get an error about narrowing in channel_algorithms.hpp. The attached patch fixes the problem and works fine with C++03 as well.

The clang version is compiled from svn, running on Ubuntu 10.04: clang version 3.2 (trunk 162287) Target: x86_64-unknown-linux-gnu Thread model: posix

Attachments (1)

boost-gil-clang-c++11-narrowing.patch (545 bytes ) - added by Jim Bosch 10 years ago.
updated patch that avoids introducing a new problem

Download all attachments as: .zip

Change History (9)

by Jim Bosch, 10 years ago

updated patch that avoids introducing a new problem

comment:1 by Jim Bosch, 10 years ago

Looking closer, my original patch would solve the problem but probably create some new ones, by always casting to unsigned int instead of the template parameter type. I've now attached a new patch that avoids mistake.

It also looks like one of the partial specializations of the template in the same area could cause problems for C++11, depending on the types it was instantiated with. I'll leave fixing that up to someone more familiar with its purpose.

comment:2 by chhenning, 10 years ago

Resolution: fixed
Status: newclosed

This has been fixed. See ticket 7970

comment:3 by babatakao@…, 6 years ago

Resolution: fixed
Status: closedreopened
Version: Boost 1.51.0Boost 1.63.0

boost 1.61 still causes the error with clang: Apple LLVM version 7.3.0 (clang-703.0.31)

/buildroot/libs/boost/include/boost/gil/channel_algorithm.hpp:55:85: error: non-type template argument evaluates to -1, which cannot be narrowed to type 'unsigned long' [-Wc++11-narrowing]
struct unsigned_integral_max_value : public mpl::integral_c<UnsignedIntegralChannel,-1> {};
                                                                                    ^
/buildroot/libs/boost/include/boost/gil/channel_algorithm.hpp:55:85: /libs/boost/include/boost/gil/channel_algorithm.hpp:205:19: note: in instantiation of template class 'boost::gil::detail::unsigned_integral_max_value<unsigned long>' requested here
        if (src > unsigned_integral_max_value<uintmax_t>::value - div2)
                  ^
1 error generated.

and it does not seem to be fixed on boost 1.63.0 beta1.

(The error occurs only if "-std=c++11" is given.)

"boost-gil-clang-c++11-narrowing.patch" fixes the error.

comment:4 by Mateusz Loskot, 6 years ago

Cc: mateusz@… added

comment:5 by Stefan Seefeld, 5 years ago

Owner: changed from Hailin Jin to Stefan Seefeld
Status: reopenednew

comment:6 by Mateusz Loskot, 5 years ago

Owner: changed from Stefan Seefeld to Mateusz Loskot
Status: newassigned

comment:7 by Mateusz Loskot, 5 years ago

Resolution: fixed
Status: assignedclosed

comment:8 by Mateusz Loskot, 5 years ago

Milestone: To Be DeterminedBoost 1.68.0
Note: See TracTickets for help on using tickets.