[Bug libstdc++/92850] New: clang has already supported concepts in latest trunk. However it does not define __cpp_concepts macro. I defined it but crashes clang compiler

euloanty at live dot com gcc-bugzilla@gcc.gnu.org
Sat Dec 7 00:40:00 GMT 2019


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92850

            Bug ID: 92850
           Summary: clang has already supported concepts in latest trunk.
                    However it does not define __cpp_concepts macro. I
                    defined it but crashes clang compiler
           Product: gcc
           Version: 10.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libstdc++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: euloanty at live dot com
  Target Milestone: ---

#include<concepts>
#include<ranges>
#include<vector>

int main()
{
        std::ranges::contiguous_range auto& vec(std::vector<std::size_t>());
}

//fails to compile with  clang++ -o a a.cc -Ofast -std=c++2a -s

a.cc:7:7: error: no member named 'ranges' in namespace 'std'
        std::ranges::contiguous_range auto& vec(std::vector<std::size_t>());
        ~~~~~^
a.cc:7:41: warning: parentheses were disambiguated as a function declaration
[-Wvexing-parse]
        std::ranges::contiguous_range auto& vec(std::vector<std::size_t>());
                                               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:7:42: note: add a pair of parentheses to declare a variable
        std::ranges::contiguous_range auto& vec(std::vector<std::size_t>());
                                                ^
                                                (                         )
1 warning and 1 error generated.

//crashes with clang++ -o a a.cc -Ofast -std=c++2a -s -D__cpp_concepts=201907L

In file included from a.cc:1:
/usr/local/bin/../lib/gcc/x86_64-pc-linux-gnu/10.0.0/../../../../include/c++/10.0.0/concepts:73:10:
error: expected expression
      && requires(add_rvalue_reference_t<_From> (&__f)()) {
         ^
/usr/local/bin/../lib/gcc/x86_64-pc-linux-gnu/10.0.0/../../../../include/c++/10.0.0/concepts:81:10:
error: use of undeclared identifier 'convertible_to'
      && convertible_to<_Tp, common_reference_t<_Tp, _Up>>
         ^
/usr/local/bin/../lib/gcc/x86_64-pc-linux-gnu/10.0.0/../../../../include/c++/10.0.0/concepts:82:10:
error: use of undeclared identifier 'convertible_to'
      && convertible_to<_Up, common_reference_t<_Tp, _Up>>;
         ^
/usr/local/bin/../lib/gcc/x86_64-pc-linux-gnu/10.0.0/../../../../include/c++/10.0.0/concepts:88:10:
error: expected expression
      && requires {
         ^
/usr/local/bin/../lib/gcc/x86_64-pc-linux-gnu/10.0.0/../../../../include/c++/10.0.0/concepts:128:10:
error: expected expression
      && requires(_Lhs __lhs, _Rhs&& __rhs) {
         ^
/usr/local/bin/../lib/gcc/x86_64-pc-linux-gnu/10.0.0/../../../../include/c++/10.0.0/concepts:127:10:
error: use of undeclared identifier 'common_reference_with'
      && common_reference_with<__detail::__cref<_Lhs>, __detail::__cref<_Rhs>>
         ^
/usr/local/bin/../lib/gcc/x86_64-pc-linux-gnu/10.0.0/../../../../include/c++/10.0.0/concepts:144:10:
error: expected expression
      && requires
         ^
/usr/local/bin/../lib/gcc/x86_64-pc-linux-gnu/10.0.0/../../../../include/c++/10.0.0/concepts:153:39:
error: use of undeclared identifier 'convertible_to'
    = constructible_from<_Tp, _Tp> && convertible_to<_Tp, _Tp>;
                                      ^
/usr/local/bin/../lib/gcc/x86_64-pc-linux-gnu/10.0.0/../../../../include/c++/10.0.0/concepts:158:9:
error: use of undeclared identifier 'move_constructible'
      = move_constructible<_Tp>
        ^
/usr/local/bin/../lib/gcc/x86_64-pc-linux-gnu/10.0.0/../../../../include/c++/10.0.0/concepts:159:43:
error: use of undeclared identifier 'convertible_to'
      && constructible_from<_Tp, _Tp&> && convertible_to<_Tp&, _Tp>
                                          ^
/usr/local/bin/../lib/gcc/x86_64-pc-linux-gnu/10.0.0/../../../../include/c++/10.0.0/concepts:160:49:
error: use of undeclared identifier 'convertible_to'
      && constructible_from<_Tp, const _Tp&> && convertible_to<const _Tp&, _Tp>
                                                ^
/usr/local/bin/../lib/gcc/x86_64-pc-linux-gnu/10.0.0/../../../../include/c++/10.0.0/concepts:161:48:
error: use of undeclared identifier 'convertible_to'
      && constructible_from<_Tp, const _Tp> && convertible_to<const _Tp, _Tp>;
                                               ^
/usr/local/bin/../lib/gcc/x86_64-pc-linux-gnu/10.0.0/../../../../include/c++/10.0.0/concepts:175:7:
error: expected expression
          && requires(_Tp&& __t, _Up&& __u) {
             ^
/usr/local/bin/../lib/gcc/x86_64-pc-linux-gnu/10.0.0/../../../../include/c++/10.0.0/concepts:195:13:
error: use of undeclared identifier '__adl_swap'
          requires __adl_swap<_Tp, _Up>
                   ^
/usr/local/bin/../lib/gcc/x86_64-pc-linux-gnu/10.0.0/../../../../include/c++/10.0.0/concepts:197:11:
error: use of undeclared identifier 'move_constructible'
              && move_constructible<remove_reference_t<_Tp>>
                 ^
/usr/local/bin/../lib/gcc/x86_64-pc-linux-gnu/10.0.0/../../../../include/c++/10.0.0/concepts:198:11:
error: use of undeclared identifier 'assignable_from'
              && assignable_from<_Tp, remove_reference_t<_Tp>>)
                 ^
/usr/local/bin/../lib/gcc/x86_64-pc-linux-gnu/10.0.0/../../../../include/c++/10.0.0/concepts:186:20:
error: use of undeclared identifier '__adl_swap'; did you mean '__sync_swap'?
            if constexpr (__adl_swap<_Tp, _Up>)
                          ^
/usr/local/bin/../lib/gcc/x86_64-pc-linux-gnu/10.0.0/../../../../include/c++/10.0.0/concepts:195:13:
note: '__sync_swap' declared here
          requires __adl_swap<_Tp, _Up>
                   ^
Stack dump:
0.      Program arguments: /usr/local/bin/clang-10 -cc1 -triple
x86_64-unknown-linux-gnu -emit-obj -disable-free -disable-llvm-verifier
-discard-value-names -main-file-name a.cc -mrelocation-model static
-mthread-model posix -mframe-pointer=none -menable-no-infs -menable-no-nans
-menable-unsafe-fp-math -fno-signed-zeros -mreassociate -freciprocal-math
-ffp-contract=fast -fno-rounding-math -ffast-math -ffinite-math-only
-masm-verbose -mconstructor-aliases -munwind-tables -fuse-init-array
-target-cpu x86-64 -dwarf-column-info -debugger-tuning=gdb -resource-dir
/usr/local/lib/clang/10.0.0 -D __cpp_concepts=201907L -internal-isystem
/usr/local/bin/../lib/gcc/x86_64-pc-linux-gnu/10.0.0/../../../../include/c++/10.0.0
-internal-isystem
/usr/local/bin/../lib/gcc/x86_64-pc-linux-gnu/10.0.0/../../../../include/c++/10.0.0/x86_64-pc-linux-gnu
-internal-isystem
/usr/local/bin/../lib/gcc/x86_64-pc-linux-gnu/10.0.0/../../../../include/c++/10.0.0/backward
-internal-isystem /usr/local/include -internal-isystem
/usr/local/lib/clang/10.0.0/include -internal-externc-isystem
/usr/include/x86_64-linux-gnu -internal-externc-isystem /include
-internal-externc-isystem /usr/include -Ofast -std=c++2a -fdeprecated-macro
-fdebug-compilation-dir /mnt/d/hg/fast_io/examples/0000.Hello World
-ferror-limit 19 -fmessage-length 0 -fgnuc-version=4.2.1 -fno-implicit-modules
-fobjc-runtime=gcc -fcxx-exceptions -fexceptions -fdiagnostics-show-option
-fcolor-diagnostics -vectorize-loops -vectorize-slp -faddrsig -o
/tmp/a-94c4ee.o -x c++ a.cc
1.     
/usr/local/bin/../lib/gcc/x86_64-pc-linux-gnu/10.0.0/../../../../include/c++/10.0.0/concepts:186:40:
current parser token ')'
2.     
/usr/local/bin/../lib/gcc/x86_64-pc-linux-gnu/10.0.0/../../../../include/c++/10.0.0/concepts:46:1:
parsing namespace 'std'
3.     
/usr/local/bin/../lib/gcc/x86_64-pc-linux-gnu/10.0.0/../../../../include/c++/10.0.0/concepts:165:3:
parsing namespace 'std::ranges'
4.     
/usr/local/bin/../lib/gcc/x86_64-pc-linux-gnu/10.0.0/../../../../include/c++/10.0.0/concepts:167:5:
parsing namespace 'std::ranges::__cust_swap'
5.     
/usr/local/bin/../lib/gcc/x86_64-pc-linux-gnu/10.0.0/../../../../include/c++/10.0.0/concepts:179:7:
parsing struct/union/class body 'std::ranges::__cust_swap::_Swap'
6.     
/usr/local/bin/../lib/gcc/x86_64-pc-linux-gnu/10.0.0/../../../../include/c++/10.0.0/concepts:185:4:
parsing function body 'std::ranges::__cust_swap::_Swap::_S_noexcept'
7.     
/usr/local/bin/../lib/gcc/x86_64-pc-linux-gnu/10.0.0/../../../../include/c++/10.0.0/concepts:185:4:
in compound statement ('{}')
 #0 0x0000000002140d64 PrintStackTraceSignalHandler(void*)
(/usr/local/bin/clang-10+0x2140d64)
 #1 0x000000000213eaee llvm::sys::RunSignalHandlers()
(/usr/local/bin/clang-10+0x213eaee)
 #2 0x000000000214114c SignalHandler(int) (/usr/local/bin/clang-10+0x214114c)
 #3 0x00007efbff2ca890 __restore_rt
(/lib/x86_64-linux-gnu/libpthread.so.0+0x12890)
 #4 0x00007efbfe0c0f75 (/lib/x86_64-linux-gnu/libc.so.6+0x16ef75)
 #5 0x0000000003f46932 clang::Expr::EvaluateKnownConstInt(clang::ASTContext
const&, llvm::SmallVectorImpl<std::pair<clang::SourceLocation,
clang::PartialDiagnostic> >*) const (/usr/local/bin/clang-10+0x3f46932)
 #6 0x000000000395f216 clang::Sema::ActOnCondition(clang::Scope*,
clang::SourceLocation, clang::Expr*, clang::Sema::ConditionKind)
(/usr/local/bin/clang-10+0x395f216)
 #7 0x00000000035e54df
clang::Parser::ParseCXXCondition(clang::ActionResult<clang::Stmt*, true>*,
clang::SourceLocation, clang::Sema::ConditionKind,
clang::Parser::ForRangeInfo*) (/usr/local/bin/clang-10+0x35e54df)
 #8 0x000000000361dfa2
clang::Parser::ParseParenExprOrCondition(clang::ActionResult<clang::Stmt*,
true>*, clang::Sema::ConditionResult&, clang::SourceLocation,
clang::Sema::ConditionKind) (/usr/local/bin/clang-10+0x361dfa2)
 #9 0x0000000003619000 clang::Parser::ParseIfStatement(clang::SourceLocation*)
(/usr/local/bin/clang-10+0x3619000)
#10 0x0000000003616622
clang::Parser::ParseStatementOrDeclarationAfterAttributes(llvm::SmallVector<clang::Stmt*,
32u>&, clang::Parser::ParsedStmtContext, clang::SourceLocation*,
clang::Parser::ParsedAttributesWithRange&) (/usr/local/bin/clang-10+0x3616622)
#11 0x0000000003615e71
clang::Parser::ParseStatementOrDeclaration(llvm::SmallVector<clang::Stmt*,
32u>&, clang::Parser::ParsedStmtContext, clang::SourceLocation*)
(/usr/local/bin/clang-10+0x3615e71)
#12 0x000000000361d8f1 clang::Parser::ParseCompoundStatementBody(bool)
(/usr/local/bin/clang-10+0x361d8f1)
#13 0x000000000361e725 clang::Parser::ParseFunctionStatementBody(clang::Decl*,
clang::Parser::ParseScope&) (/usr/local/bin/clang-10+0x361e725)
#14 0x000000000359183c
clang::Parser::ParseLexedMethodDef(clang::Parser::LexedMethod&)
(/usr/local/bin/clang-10+0x359183c)
#15 0x000000000359087e
clang::Parser::ParseLexedMethodDefs(clang::Parser::ParsingClass&)
(/usr/local/bin/clang-10+0x359087e)
#16 0x00000000035bc48f
clang::Parser::ParseCXXMemberSpecification(clang::SourceLocation,
clang::SourceLocation, clang::Parser::ParsedAttributesWithRange&, unsigned int,
clang::Decl*) (/usr/local/bin/clang-10+0x35bc48f)
#17 0x00000000035ba1b6
clang::Parser::ParseClassSpecifier(clang::tok::TokenKind,
clang::SourceLocation, clang::DeclSpec&, clang::Parser::ParsedTemplateInfo
const&, clang::AccessSpecifier, bool, clang::Parser::DeclSpecContext,
clang::Parser::ParsedAttributesWithRange&) (/usr/local/bin/clang-10+0x35ba1b6)
#18 0x000000000359d2a5
clang::Parser::ParseDeclarationSpecifiers(clang::DeclSpec&,
clang::Parser::ParsedTemplateInfo const&, clang::AccessSpecifier,
clang::Parser::DeclSpecContext, clang::Parser::LateParsedAttrList*)
(/usr/local/bin/clang-10+0x359d2a5)
#19 0x0000000003587dec
clang::Parser::ParseDeclOrFunctionDefInternal(clang::Parser::ParsedAttributesWithRange&,
clang::ParsingDeclSpec&, clang::AccessSpecifier)
(/usr/local/bin/clang-10+0x3587dec)
#20 0x0000000003587bb5
clang::Parser::ParseDeclarationOrFunctionDefinition(clang::Parser::ParsedAttributesWithRange&,
clang::ParsingDeclSpec*, clang::AccessSpecifier)
(/usr/local/bin/clang-10+0x3587bb5)
#21 0x0000000003586d34
clang::Parser::ParseExternalDeclaration(clang::Parser::ParsedAttributesWithRange&,
clang::ParsingDeclSpec*) (/usr/local/bin/clang-10+0x3586d34)
#22 0x00000000035b385a
clang::Parser::ParseInnerNamespace(llvm::SmallVector<clang::Parser::InnerNamespaceInfo,
4u> const&, unsigned int, clang::SourceLocation&, clang::ParsedAttributes&,
clang::BalancedDelimiterTracker&) (/usr/local/bin/clang-10+0x35b385a)
#23 0x00000000035b3429 clang::Parser::ParseNamespace(clang::DeclaratorContext,
clang::SourceLocation&, clang::SourceLocation)
(/usr/local/bin/clang-10+0x35b3429)
#24 0x000000000359c9ed
clang::Parser::ParseDeclaration(clang::DeclaratorContext,
clang::SourceLocation&, clang::Parser::ParsedAttributesWithRange&,
clang::SourceLocation*) (/usr/local/bin/clang-10+0x359c9ed)
#25 0x00000000035862a0
clang::Parser::ParseExternalDeclaration(clang::Parser::ParsedAttributesWithRange&,
clang::ParsingDeclSpec*) (/usr/local/bin/clang-10+0x35862a0)
#26 0x00000000035b385a
clang::Parser::ParseInnerNamespace(llvm::SmallVector<clang::Parser::InnerNamespaceInfo,
4u> const&, unsigned int, clang::SourceLocation&, clang::ParsedAttributes&,
clang::BalancedDelimiterTracker&) (/usr/local/bin/clang-10+0x35b385a)
#27 0x00000000035b3429 clang::Parser::ParseNamespace(clang::DeclaratorContext,
clang::SourceLocation&, clang::SourceLocation)
(/usr/local/bin/clang-10+0x35b3429)
#28 0x000000000359c9ed
clang::Parser::ParseDeclaration(clang::DeclaratorContext,
clang::SourceLocation&, clang::Parser::ParsedAttributesWithRange&,
clang::SourceLocation*) (/usr/local/bin/clang-10+0x359c9ed)
#29 0x00000000035862a0
clang::Parser::ParseExternalDeclaration(clang::Parser::ParsedAttributesWithRange&,
clang::ParsingDeclSpec*) (/usr/local/bin/clang-10+0x35862a0)
#30 0x00000000035b385a
clang::Parser::ParseInnerNamespace(llvm::SmallVector<clang::Parser::InnerNamespaceInfo,
4u> const&, unsigned int, clang::SourceLocation&, clang::ParsedAttributes&,
clang::BalancedDelimiterTracker&) (/usr/local/bin/clang-10+0x35b385a)
#31 0x00000000035b3429 clang::Parser::ParseNamespace(clang::DeclaratorContext,
clang::SourceLocation&, clang::SourceLocation)
(/usr/local/bin/clang-10+0x35b3429)
#32 0x000000000359c9ed
clang::Parser::ParseDeclaration(clang::DeclaratorContext,
clang::SourceLocation&, clang::Parser::ParsedAttributesWithRange&,
clang::SourceLocation*) (/usr/local/bin/clang-10+0x359c9ed)
#33 0x00000000035862a0
clang::Parser::ParseExternalDeclaration(clang::Parser::ParsedAttributesWithRange&,
clang::ParsingDeclSpec*) (/usr/local/bin/clang-10+0x35862a0)
#34 0x0000000003584e1a
clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&, bool)
(/usr/local/bin/clang-10+0x3584e1a)
#35 0x00000000035802d8 clang::ParseAST(clang::Sema&, bool, bool)
(/usr/local/bin/clang-10+0x35802d8)
#36 0x00000000027bd922 clang::FrontendAction::Execute()
(/usr/local/bin/clang-10+0x27bd922)
#37 0x000000000275a6cf
clang::CompilerInstance::ExecuteAction(clang::FrontendAction&)
(/usr/local/bin/clang-10+0x275a6cf)
#38 0x000000000285cbaa
clang::ExecuteCompilerInvocation(clang::CompilerInstance*)
(/usr/local/bin/clang-10+0x285cbaa)
#39 0x00000000009ce203 cc1_main(llvm::ArrayRef<char const*>, char const*,
void*) (/usr/local/bin/clang-10+0x9ce203)
#40 0x00000000009cc089 main (/usr/local/bin/clang-10+0x9cc089)
#41 0x00007efbfdf73b97 __libc_start_main
(/lib/x86_64-linux-gnu/libc.so.6+0x21b97)
#42 0x00000000009c94aa _start (/usr/local/bin/clang-10+0x9c94aa)
clang-10: error: unable to execute command: Segmentation fault
clang-10: error: clang frontend command failed due to signal (use -v to see
invocation)
clang version 10.0.0 (https://github.com/llvm/llvm-project.git
84fdd9d7a50b9b41148e5ae8b93bfc4d2613feea)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /usr/local/bin
clang-10: note: diagnostic msg: PLEASE submit a bug report to  and include the
crash backtrace, preprocessed source, and associated run script.
clang-10: note: diagnostic msg:
********************

PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
Preprocessed source(s) and associated run script(s) are located at:
clang-10: note: diagnostic msg: /tmp/a-056fca.cpp
clang-10: note: diagnostic msg: /tmp/a-056fca.sh
clang-10: note: diagnostic msg:

********************


More information about the Gcc-bugs mailing list