Opened 9 years ago

Closed 5 years ago

Last modified 5 years ago

#9517 closed Bugs (fixed)

boost gil compile error because of type narrowing

Reported by: ryan.burn@… Owned by: Mateusz Loskot
Milestone: Boost 1.68.0 Component: gil USE GITHUB
Version: Boost 1.54.0 Severity: Problem
Keywords: Cc: william@…, mateusz@…

Description

line 204 in boost/gil/channel_algorithm.hpp if (src > unsigned_integral_max_value<uintmax_t>::value - div2) gives me this error with clang 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> {};

can you just replace with std::numeric_limits<unitmax_t>::max()?

Attachments (1)

gil_channel_algorithm.patch (692 bytes ) - added by frederic.bron@… 5 years ago.
patch

Download all attachments as: .zip

Change History (11)

comment:1 by william@…, 8 years ago

Cc: william@… added

This error persists in Boost 1.55 using clang of Xcode 5.1 on Mac OS 10.9 (Don't see how to select multiple values for the version field here!)

comment:2 by William Gallafent <william@…>, 8 years ago

… incidentally, I went for a std:: numeric_limits <UnsignedIntegralChannel>:: max () instead … not sure which is more correct in this context.

comment:3 by anonymous, 7 years ago

I am facing the same problem in the same file, with Boost 1.57, on line 54. Does someone knows the status of this ?

comment:4 by Mateusz Loskot, 6 years ago

Cc: mateusz@… added

by frederic.bron@…, 5 years ago

Attachment: gil_channel_algorithm.patch added

patch

comment:5 by frederic.bron@…, 5 years ago

This is easy to to fix. integral_c is defined by: template< typename T, T N > struct integral_c;

So the 2nd template parameter is of type T=UnsignedIntegralChannel.

Therefore, -1 can easily be replaced by either std::numeric_limits<UnsignedIntegralChannel>::max() or static_cast<UnsignedIntegralChannel>(-1)

See patch attached.

comment:6 by Stefan Seefeld, 5 years ago

Owner: changed from Hailin Jin to Stefan Seefeld

comment:7 by Mateusz Loskot, 5 years ago

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

comment:8 by Mateusz Loskot, 5 years ago

Resolution: fixed
Status: assignedclosed

Duplicate of #7270 (already fixed)

comment:9 by Mateusz Loskot, 5 years ago

Version: Boost 1.54.0Boost Development Trunk

comment:10 by Mateusz Loskot, 5 years ago

Milestone: To Be DeterminedBoost 1.68.0
Version: Boost Development TrunkBoost 1.54.0
Note: See TracTickets for help on using tickets.