#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)
Change History (9)
by , 10 years ago
| Attachment: | boost-gil-clang-c++11-narrowing.patch added | 
|---|
comment:1 by , 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 , 10 years ago
| Resolution: | → fixed | 
|---|---|
| Status: | new → closed | 
This has been fixed. See ticket 7970
comment:3 by , 6 years ago
| Resolution: | fixed | 
|---|---|
| Status: | closed → reopened | 
| Version: | Boost 1.51.0 → Boost 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 , 6 years ago
| Cc: | added | 
|---|
comment:5 by , 5 years ago
| Owner: | changed from to | 
|---|---|
| Status: | reopened → new | 
comment:6 by , 5 years ago
| Owner: | changed from to | 
|---|---|
| Status: | new → assigned | 
comment:7 by , 5 years ago
| Resolution: | → fixed | 
|---|---|
| Status: | assigned → closed | 
This should have been fixed by https://github.com/boostorg/gil/commit/e3cba43c16e1958e8dac1ca9cb5745d9d6a68068 (Feb 6, 2013)
comment:8 by , 5 years ago
| Milestone: | To Be Determined → Boost 1.68.0 | 
|---|


updated patch that avoids introducing a new problem