saarraz / clang-concepts-monorepo

****** OBSOLETE - CONCEPTS HAS BEEN MERGED INTO CLANG TRUNK AND DEVELOPMENT CONTINUES THERE ****** This fork of llvm-project contains my implementation of C++2a Concepts for the Clang compiler, and will be updated regularly with bug fixes until the whole feature is merged to trunk. Follow the instructions here https://clang.llvm.org/get_started.html to build, then use the flags "-std=c++2a -Xclang -fconcepts-ts" to enable concepts.
27 stars 3 forks source link

Should not define __cpp_concepts #1

Open davidstone opened 5 years ago

davidstone commented 5 years ago

libstdc++ uses __cpp_concepts to check if concepts are enabled. Unfortunately, it is going off a very old version of concepts that did not require parenthesizing expressions that are not just concepts or just a value of type bool. This means that using clang with libstdc++ gives error messages like:

/usr/lib/gcc/x86_64-pc-linux-gnu/9.1.0/include/g++-v9/memory:232:14: error: expected primary expression before '!'; did you forget parentheses? requires ! _Std_pair<_Tp>

davidstone commented 5 years ago

See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91259 for the bug report against gcc

saarraz commented 5 years ago

I'm not sure if this is a bug on our side or not... Checking with caseycarter who added this macro originally.

davidstone commented 5 years ago

Looks like this is fixed on trunk for libstdc++: https://gcc.gnu.org/ml/gcc-patches/2019-07/msg01090.html . However, clang claims libstdc++ compatibility, so it cannot define __cpp_concepts for this version of gcc unless it accepts the code.

saarraz commented 5 years ago

Anyway the solution here is not to undefine __cpp_concepts but rather to set it to the correct value. In this specific case it wouldn't matter because libstdc++ simply checked for the non-zeroness of the __cpp_concepts flag and not for its value, which is in any case a bug on their end.