Search code examples
linuxclang++

clang++ error on standard library depending on -std=c++2b version and warning when using -g flag


While compilation with g++ works correctly if I compile with clang++ the command bellow compiles correctly

clang++ -std=gnu++20 -c 03_vect.cpp -o Debug/03_vect.cpp.o

while the command bellow

clang++ -std=gnu++2b -c 03_vect.cpp -o Debug/03_vect.cpp.o;ls -l Debug/03_vect.cpp.o

gives

In file included from 03_vect.cpp:1:
In file included from ./00_usefull_macros.h:13:
In file included from /usr/bin/../lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/iostream:41:
In file included from /usr/bin/../lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/ostream:40:
In file included from /usr/bin/../lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/ios:44:
In file included from /usr/bin/../lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/bits/ios_base.h:41:
In file included from /usr/bin/../lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/bits/locale_classes.h:40:
In file included from /usr/bin/../lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/string:48:
/usr/bin/../lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/bits/stl_iterator.h:2618:35: error: missing 'typename' prior to dependent type name 'iterator_traits<_It>::iterator_category'
      { using iterator_category = iterator_traits<_It>::iterator_category; };

Moreover if I compile with the flag -g it gives warning:

03_vect.s:8:2: warning: inconsistent use of MD5 checksums .file 1 "03_vect.cpp"

Any experience on the above ?


Solution

  • You need clang-16. Earlier versions do not implement P0634R3. libstdc++ uses this feature in the c++2b mode.