Boost logo

Boost :

Subject: Re: Default value of pixel channel (homogeneous_color_base)
From: Mateusz Loskot (mateusz_at_[hidden])
Date: 2019-03-02 22:04:49


On 19-03-01 01:38:20, Mateusz Loskot wrote:
>Hi,
>
>Is there any particular reason channel values of pixel, i.e. elements of
>homogeneous_color_base [1] have indetermined value if
>default-constructed?
>
>For example, AFAIU, because of essentially this [1]
>
>struct homogeneous_color_base<Element,Layout,1> {
> Element _v0;
> homogeneous_color_base() {}
>};
>
>the following is not guaranteed, is it?
>
>rgb8_pixel_t{} == rgb8_pixel_t{}
>
>[2] "[if] they should be default constructible, they should initialize their
>contents with some sensible values. If they decide that they should not be
>default constructible, they should delete the constructors to avoid issues."
>
>
>[1] https://github.com/boostorg/gil/blob/develop/include/boost/gil/color_base.hpp
>[2] https://blog.tartanllama.xyz/initialization-is-bonkers/

Related issues have been observed as part of test/pixel/test_fixture.cpp
and discussed briefly on Gitter. Here is summary:

https://github.com/boostorg/gil/pull/248#issuecomment-468964512

This needs to be investigated further.

Best regards,

-- 
Mateusz Loskot, http://mateusz.loskot.net

Boost list run by Boost-Gil-Owners