Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DeviceN support for N=2 broke in Boost 1.72 #519

Closed
dmwilk opened this issue Sep 9, 2020 · 3 comments · Fixed by #654
Closed

DeviceN support for N=2 broke in Boost 1.72 #519

dmwilk opened this issue Sep 9, 2020 · 3 comments · Fixed by #654
Labels
cat/bug But reports and bug fixes
Milestone

Comments

@dmwilk
Copy link

dmwilk commented Sep 9, 2020

Existing code using any of the boost::gil::dev2n32f types (defined in typedefs.hpp) fails because of explicit static assertion check. I would expect if gil is going to continue defining these types that they continue to compile; explicit exclusion of support for channels=2 is surprising given the number of useful formats this represents (2D flow vectors, grayscale images with alpha, duotones)

My system uses DeviceN=2 extensively & refactoring is a nontrivial endeavor

C++ Minimal Working Example

int main
{
	boost::gil::dev2n32f_pixel_t	this_wont_compile;    // defined in typedefs.hpp
	boost::gil::dev3n32f_pixel_t	this_does_compile;

	boost::gil::image<boost::gil::dev2n32f_pixel_t, false>		nope;
	boost::gil::image<boost::gil::dev3n32f_pixel_t, false>		yep;
        return 0;
}

failure is in a static_assert expressing non-implementation so should be same in all compilers

@striezel
Copy link
Contributor

striezel commented Apr 29, 2022

failure is in a static_assert expressing non-implementation so should be same in all compilers

Possibly yes, but in my opinion it would have been a good idea to include the message here nonetheless, so people might get a better idea where to look when trying to fix this error.

Using the provided minimal working example (MWE)

#include <boost/gil.hpp>

int main()
{
	boost::gil::dev2n32f_pixel_t	this_wont_compile;    // defined in typedefs.hpp
	boost::gil::dev3n32f_pixel_t	this_does_compile;

	boost::gil::image<boost::gil::dev2n32f_pixel_t, false>		nope;
	boost::gil::image<boost::gil::dev3n32f_pixel_t, false>		yep;
        return 0;
}

I get the following error in GCC 11.2.0 using the current master from boostorg/boost@38e705a:

$ g++ main.cpp 
In file included from /usr/include/boost/gil/typedefs.hpp:13,
                 from /usr/include/boost/gil/channel_algorithm.hpp:13,
                 from /usr/include/boost/gil/color_convert.hpp:11,
                 from /usr/include/boost/gil/image_view_factory.hpp:11,
                 from /usr/include/boost/gil/algorithm.hpp:15,
                 from /usr/include/boost/gil.hpp:12,
                 from main.cpp:1:
/usr/include/boost/gil/device_n.hpp: In instantiation of 'struct boost::gil::devicen_t<2>':
/usr/include/boost/gil/device_n.hpp:56:8:   required from 'struct boost::gil::devicen_layout_t<2>'
/usr/include/boost/gil/pixel.hpp:99:8:   required from 'struct boost::gil::pixel<boost::gil::scoped_channel_value<float, boost::gil::float_point_zero<float>, boost::gil::float_point_one<float> >, boost::gil::devicen_layout_t<2> >'
main.cpp:5:31:   required from here
/usr/include/boost/gil/device_n.hpp:46:16: error: static assertion failed: invalid number of DeviceN color components
   46 |         N == 1 || (3 <= N && N <= 5),
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~
/usr/include/boost/gil/device_n.hpp:46:16: note: '((2 == 1) || ((3 <= 2) && (2 <= 5)))' evaluates to false

On the other hand, it compiles with Boost 1.71 just fine. Compiling with 1.72 fails, error message is the same.
The static_assert was introduced in commit 5611bd5 of PR #274.

I'll try to fix this.

striezel added a commit to striezel-stash/gil that referenced this issue Apr 29, 2022
devicen_t<2> was possible in Boost 1.71, but broke in Boost 1.72.
Now it's possible to use it again.

Fixes boostorg#519.
@striezel
Copy link
Contributor

striezel commented Apr 29, 2022

@dmwilk:
The changes in #654 fix your issue. At least your minimal working example is now indeed a working example again. :)

@mloskot mloskot added the cat/bug But reports and bug fixes label May 18, 2022
@mloskot mloskot added this to the Boost 1.80 milestone May 18, 2022
@mloskot
Copy link
Member

mloskot commented May 18, 2022

@dmwilk Thanks for reporting and thank you @striezel for the fix!

mloskot pushed a commit that referenced this issue May 18, 2022
devicen_t<2> was possible in Boost 1.71, but broke in Boost 1.72.

The static_assert was introduced in commit
5611bd5
in PR #274

Now it's possible to use it again.

Fixes #519
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cat/bug But reports and bug fixes
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants