clang-concepts-monorepo icon indicating copy to clipboard operation
clang-concepts-monorepo copied to clipboard

Should not define __cpp_concepts

Open davidstone opened this issue 6 years ago • 4 comments

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 avatar Jul 25 '19 16:07 davidstone

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

davidstone avatar Jul 25 '19 17:07 davidstone

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

saarraz avatar Jul 25 '19 18:07 saarraz

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.

davidstone avatar Jul 25 '19 18:07 davidstone

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.

saarraz avatar Jul 27 '19 14:07 saarraz