Skip to content

Overflow in channel convertion #730

@tanguimorvan

Description

@tanguimorvan

Actual behavior

Channel conversion from boost::gil::packed_channel_value to uint16_t fails due to integer overflow in channel_converter_unsigned_integral_nondivisible<SrcChannelV,DstChannelV,true,false> .

Expected behavior

The value should not overflow, producing correct results.

C++ Minimal Working Example

#include <boost/gil.hpp>
namespace gil = boost::gil;
int main
{
    boost::gil::packed_channel_value<10> packedChannelValue(3);
    //Expected 192, got 64
    uint16_t convertedValue = boost::gil::channel_convert<uint16_t>(packedChannelValue);
}

Environment

  • Compiler version: GCC 8.4.0
  • Build settings:
  • Version (Git ref or <boost/version.hpp>): 1.68 but seems to still be present in latest version.

Metadata

Metadata

Assignees

No one assigned

    Labels

    cat/bugBut reports and bug fixes

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions