weird compile errors when setting -DCMAKE_CXX_STANDARD=17

gcc-10 on ubuntu 18.04

When the python wrappers are selected be built and CMAKE_CXX_STANDARD=17 I get weird error about type_traits way down low in the c++ standard library. I think it has to do with the python bindings may be hard coding std=c++11.

I am not totally sure I understand what the issue is, but gives and error like

_Tp  does not refer to a value 
// referencing this code snippet  in type_traits
: public integral_constant<bool, _GLIBCXX_BUILTIN_IS_SAME_AS(_Tp, _Up)>

there were some other issues around throw(itk::object) which I replaced with noexcept(false) but that didn’t seemed relevant to the issue above.

I also turned off the python bindings and it appears to be compiling fine.

SWIG’s docs say:


 work has only just begun on adding C++17 support. SWIG-4.0.0 is the first version to support any C++17 features.

1 Like

that is very helpful, from pursuing it looked like itk should compile with 17 just fine, but didn’t think about it interfering with swig wrapping.

it appears to give the same error when CMAKE_CXX_STANDARD is not set. which I would assume get set to a default?

the latest cmake sets it to 14, which appears to be the same issue.

also I believe I am compiling with swig 3.x (the default), maybe using external 4.x would fix. Is it in the works to upgrade swig to 4.x in the default build settings?

I found that the default build uses swig 3.x on unix. after modifying to use 4.x the build produces the same issue.

Hi @kayarre,

How was gcc-10 installed? I would like to reproduce the issue.

Thanks,
Matt

on Ubuntu 18.04 I used the apt repo ubuntu-toolchaing-r/test

apt install gcc-10 g+±10 gfortran-10.
Kurt

1 Like

Thanks, Kurt. I was able to reproduce the error.

This patch addresses the build errors:

We use CastXML to parse the C++ headers to generate the wrapping interface. CastXML uses LLVM for syntax parsing. This version bumps LLVM from 6 to 10 to improve syntax support for GCC 10.