Boost logo

Boost :

Subject: [boost] [gil] gcc fail with simple code
From: Christian Henning (chhenning_at_[hidden])
Date: 2018-03-28 17:30:36


Hi all,

we are, at the boost::gil corner, investigating a runtime failure when
compiling with gcc 5.4. When running in release configuration the following
code fails:

#include <iostream>
#include <boost/gil/gil_all.hpp>

using namespace boost::gil;
using namespace std;

void error_if(bool condition) {
    if (condition)
        throw std::exception();
}

bits32s c32s_min = channel_traits<bits32s>::min_value();
bits32s c32s_max = channel_traits<bits32s>::max_value();

// For channel values simply initialize the value directly
template <typename ChannelValue>
struct value_core {
    typedef ChannelValue channel_t;
    channel_t _min_v, _max_v;

    value_core() : _min_v(channel_traits<ChannelValue>::min_value()),
_max_v(channel_traits<ChannelValue>::max_value())
    {}
};

int main(int argc, char *argv[])
{
    value_core<bits32s> a;

    bits32s v_min, v_max;

    v_min = channel_convert<bits32s>(c32s_min);
    v_max = channel_convert<bits32s>(c32s_max);

    //std::cout << v_min << std::endl;
    // std::cout << this->_min_v << std::endl;
    //std::cout << v_max << std::endl;
    // std::cout << this->_max_v << std::endl;

    error_if(v_min != a._min_v || v_max != a._max_v);
}

The interesting thing is that everything works with the cout's enabled.

Has anyone ever dealt with a similar issue?

Thanks,
Christian


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk