Hi,
I am on ubuntu 20.04, I have GCC9.4 and 10.3 and 11.1 installed.
I found that when set "-std=c++20", with gcc11, boost.gil will failed to build.
Here is the simple test cpp to reproduce the issue:
#include <sstream>
#include
#include
namespace gil = boost::gil;
int main()
{
gil::rgb8_image_t img;
std::stringstream buf(std::ios::in | std::ios::out | std::ios::binary);
gil::read_and_convert_image(buf, img, gil::png_tag{});
return 0;
}
the build command is:
g++ -o test test_gcc11_gil.cc -std=c++20 -I${THIRD_PARTY}/boost/boost_1_78_0 -L${THIRD_PARTY}/libpng/1.6.37/lib/ -lpng
If replaced '-std=c++20' with '-std=c++17', the build would be OK, but with 'c++20', gcc 11 failed with the following errors:
In file included from /data/lin/ThirdParty/boost/boost_1_78_0/boost/gil/extension/io/png/read.hpp:13,
from /data/lin/ThirdParty/boost/boost_1_78_0/boost/gil/extension/io/png.hpp:11,
from test_gcc11_gil.cc:3:
/data/lin/ThirdParty/boost/boost_1_78_0/boost/gil/extension/io/png/tags.hpp:576:32: error: expected unqualified-id before ‘)’ token
576 | image_read_info< png_tag >()
| ^
/data/lin/ThirdParty/boost/boost_1_78_0/boost/gil/extension/io/png/tags.hpp:711:36: error: expected unqualified-id before ‘)’ token
711 | image_read_settings< png_tag >()
| ^
In file included from /data/lin/ThirdParty/boost/boost_1_78_0/boost/gil/extension/io/png/read.hpp:21,
from /data/lin/ThirdParty/boost/boost_1_78_0/boost/gil/extension/io/png.hpp:11,
from test_gcc11_gil.cc:3:
/data/lin/ThirdParty/boost/boost_1_78_0/boost/gil/io/make_reader.hpp: In instantiation of ‘typename boost::gil::get_reader::type boost::gil::make_reader(Device&, const FormatTag&, const ConversionPolicy&, typename std::enable_if, boost::gil::is_format_tag<FormatTag> >, void>::type::value>::type*) [with Device = std::__cxx11::basic_stringstream<char>; FormatTag = boost::gil::png_tag; ConversionPolicy = boost::gil::detail::read_and_convertboost::gil::default_color_converter; typename boost::gil::get_reader::type = boost::gil::readerboost::gil::png_tag, boost::gil::png_tag, boost::gil::detail::read_and_convertboost::gil::default_color_converter >; typename std::enable_if, boost::gil::is_format_tag<FormatTag> >, void>::type::value>::type = void;typename boost::mp11::detail::mp_and_impl, boost::gil::is_format_tag<FormatTag> >, void>::type =std::integral_constant]’:
/data/lin/ThirdParty/boost/boost_1_78_0/boost/gil/io/read_and_convert_image.hpp:263:34: required from ‘void boost::gil::read_and_convert_image(Device&, Image&, const FormatTag&, typename std::enable_if, boost::gil::is_format_tag<FormatTag> >, void>::type::value>::type*) [with Device = std::__cxx11::basic_stringstream<char>; Image = boost::gil::image > >, false, std::allocator<unsigned char> >; FormatTag = boost::gil::png_tag; typename std::enable_if, boost::gil::is_format_tag<FormatTag> >, void>::type::value>::type = void; typename boost::mp11::detail::mp_and_impl, boost::gil::is_format_tag<FormatTag> >, void>::type = std::integral_constant]’
test_gcc11_gil.cc:11:30: required from here
/data/lin/ThirdParty/boost/boost_1_78_0/boost/gil/io/make_reader.hpp:193:30: error: no matching function for call to ‘boost::gil::image_read_settingsboost::gil::png_tag::image_read_settings()’
193 | return make_reader(file, image_read_settings<FormatTag>(), cc);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /data/lin/ThirdParty/boost/boost_1_78_0/boost/gil/extension/io/png/read.hpp:13,
from /data/lin/ThirdParty/boost/boost_1_78_0/boost/gil/extension/io/png.hpp:11,
from test_gcc11_gil.cc:3:
/data/lin/ThirdParty/boost/boost_1_78_0/boost/gil/extension/io/png/tags.hpp:718:5: note: candidate: ‘boost::gil::image_read_settingsboost::gil::png_tag::image_read_settings(const point_t&, const point_t&)’
718 | image_read_settings( const point_t& top_left
| ^~~~~~~~~~~~~~~~~~~
/data/lin/ThirdParty/boost/boost_1_78_0/boost/gil/extension/io/png/tags.hpp:718:5: note: candidate expects 2 arguments, 0 provided
/data/lin/ThirdParty/boost/boost_1_78_0/boost/gil/extension/io/png/tags.hpp:707:8: note: candidate: ‘constexpr boost::gil::image_read_settingsboost::gil::png_tag::image_read_settings(const boost::gil::image_read_settingsboost::gil::png_tag&)’
707 | struct image_read_settings< png_tag > : public image_read_settings_base
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/data/lin/ThirdParty/boost/boost_1_78_0/boost/gil/extension/io/png/tags.hpp:707:8: note: candidate expects 1 argument, 0 provided
/data/lin/ThirdParty/boost/boost_1_78_0/boost/gil/extension/io/png/tags.hpp:707:8: note: candidate: ‘constexpr boost::gil::image_read_settingsboost::gil::png_tag::image_read_settings(boost::gil::image_read_settingsboost::gil::png_tag&&)’
/data/lin/ThirdParty/boost/boost_1_78_0/boost/gil/extension/io/png/tags.hpp:707:8: note: candidate expects 1 argument, 0 provided
Only gcc 11 will fail with '-std=c++20', gcc9 and gcc 10 worked fine. I guess that gcc11 has implemented more c++20 features than gcc9 and gcc10.
Since the boost project updates more quickly than gcc, I hope this issue might be fixed in the next boost version.
Thanks,
Qiang Ren