[llvm-bugs] [Bug 49749] New: [C++20] ICE on valid: (!KnownValid && "Explicit template arguments?") in AddOverloadedCallCandidate

via llvm-bugs llvm-bugs at lists.llvm.org
Sun Mar 28 08:38:38 PDT 2021


https://bugs.llvm.org/show_bug.cgi?id=49749

            Bug ID: 49749
           Summary: [C++20] ICE on valid: (!KnownValid && "Explicit
                    template arguments?") in AddOverloadedCallCandidate
           Product: clang
           Version: trunk
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: -New Bugs
          Assignee: unassignedclangbugs at nondot.org
          Reporter: arthur.j.odwyer at gmail.com
                CC: htmldeveloper at gmail.com, llvm-bugs at lists.llvm.org,
                    neeilans at live.com, richard-llvm at metafoo.co.uk

cat >test.cpp <<EOF
// https://godbolt.org/z/TqhebWG7f
struct A {
    static int a() { return 0; }
    decltype(a < 0 > (0)) b;
};

void test_is_bool(bool t) {}
void test_is_bool(int t) {}

int main() {
    A x;
    test_is_bool(x.b);
}
EOF
clang++ -std=c++20 -c test.cpp


The symptom is an assert-fail, so this reproduces only when Clang is built in
debug mode.

Clang's treatment of `a < 0 > (0)` seems to have changed from C++17 mode to
C++20 mode: Clang-built-without-assertions rejects this code in C++20 mode but
accepts it in C++17 mode. GCC trunk rejects this code in ALL language modes.
GCC 10.2, MSVC, ICC accept this code in ALL language modes.


Here's Clang's output for the above program (when built with assertions
enabled).
============

test.cpp:4:14: error: member 'a' used before its declaration
    decltype(a < 0 > (0)) b;
             ^
test.cpp:3:16: note: member is declared here
    static int a() { return 0; }
               ^
Assertion failed: (!KnownValid && "Explicit template arguments?"), function
AddOverloadedCallCandidate, file
/Users/aodwyer/llvm-project/clang/lib/Sema/SemaOverload.cpp, line 12602.
PLEASE submit a bug report to https://bugs.llvm.org/ and include the crash
backtrace, preprocessed source, and associated run script.
Stack dump:
0.      Program arguments: /Users/aodwyer/llvm-project/build-debug/bin/clang++
-std=c++20 -c test.cpp
1.      test.cpp:4:24: current parser token ')'
2.      test.cpp:2:1: parsing struct/union/class body 'A'
Stack dump without symbol names (ensure you have llvm-symbolizer in your PATH
or set the environment var `LLVM_SYMBOLIZER_PATH` to point to it):
0  clang++                  0x0000000104edb63d
llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) + 61
1  clang++                  0x0000000104edbbbb
PrintStackTraceSignalHandler(void*) + 27
2  clang++                  0x0000000104ed9b13 llvm::sys::RunSignalHandlers() +
115
3  clang++                  0x0000000104edaede
llvm::sys::CleanupOnSignal(unsigned long) + 110
4  clang++                  0x0000000104d79b20 (anonymous
namespace)::CrashRecoveryContextImpl::HandleCrash(int, unsigned long) + 192
5  clang++                  0x0000000104d79e73 CrashRecoverySignalHandler(int)
+ 195
6  libsystem_platform.dylib 0x00007fff697a5b5d _sigtramp + 29
7  libsystem_platform.dylib 000000000000000000 _sigtramp + 18446603338746537152
8  libsystem_c.dylib        0x00007fff6965f6a6 abort + 127
9  libsystem_c.dylib        0x00007fff6962820d basename_r + 0
10 clang++                  0x00000001095c3653
AddOverloadedCallCandidate(clang::Sema&, clang::DeclAccessPair,
clang::TemplateArgumentListInfo*, llvm::ArrayRef<clang::Expr*>,
clang::OverloadCandidateSet&, bool, bool) + 243
11 clang++                  0x00000001095c346c
clang::Sema::AddOverloadedCallCandidates(clang::UnresolvedLookupExpr*,
llvm::ArrayRef<clang::Expr*>, clang::OverloadCandidateSet&, bool) + 780
12 clang++                  0x00000001095c3c6a
clang::Sema::buildOverloadedCallSet(clang::Scope*, clang::Expr*,
clang::UnresolvedLookupExpr*, llvm::MutableArrayRef<clang::Expr*>,
clang::SourceLocation, clang::OverloadCandidateSet*,
clang::ActionResult<clang::Expr*, true>*) + 826
13 clang++                  0x00000001095c4285
clang::Sema::BuildOverloadedCallExpr(clang::Scope*, clang::Expr*,
clang::UnresolvedLookupExpr*, clang::SourceLocation,
llvm::MutableArrayRef<clang::Expr*>, clang::SourceLocation, clang::Expr*, bool,
bool) + 373
14 clang++                  0x0000000108f982e3
clang::Sema::BuildCallExpr(clang::Scope*, clang::Expr*, clang::SourceLocation,
llvm::MutableArrayRef<clang::Expr*>, clang::SourceLocation, clang::Expr*, bool,
bool) + 2467
15 clang++                  0x00000001095e6cf5
BuildRecoveryCallExpr(clang::Sema&, clang::Scope*, clang::Expr*,
clang::UnresolvedLookupExpr*, clang::SourceLocation,
llvm::MutableArrayRef<clang::Expr*>, clang::SourceLocation, bool, bool) + 1925
16 clang++                  0x00000001095c4816
FinishOverloadedCallExpr(clang::Sema&, clang::Scope*, clang::Expr*,
clang::UnresolvedLookupExpr*, clang::SourceLocation,
llvm::MutableArrayRef<clang::Expr*>, clang::SourceLocation, clang::Expr*,
clang::OverloadCandidateSet*, clang::OverloadCandidate**,
clang::OverloadingResult, bool) + 774
17 clang++                  0x00000001095c43c1
clang::Sema::BuildOverloadedCallExpr(clang::Scope*, clang::Expr*,
clang::UnresolvedLookupExpr*, clang::SourceLocation,
llvm::MutableArrayRef<clang::Expr*>, clang::SourceLocation, clang::Expr*, bool,
bool) + 689
18 clang++                  0x0000000108f982e3
clang::Sema::BuildCallExpr(clang::Scope*, clang::Expr*, clang::SourceLocation,
llvm::MutableArrayRef<clang::Expr*>, clang::SourceLocation, clang::Expr*, bool,
bool) + 2467
19 clang++                  0x0000000108fb927f
clang::Sema::ActOnCallExpr(clang::Scope*, clang::Expr*, clang::SourceLocation,
llvm::MutableArrayRef<clang::Expr*>, clang::SourceLocation, clang::Expr*) + 143
20 clang++                  0x000000010878055e
clang::Parser::ParsePostfixExpressionSuffix(clang::ActionResult<clang::Expr*,
true>) + 5742
21 clang++                  0x0000000108787234
clang::Parser::ParseCastExpression(clang::Parser::CastParseKind, bool, bool&,
clang::Parser::TypeCastState, bool, bool*) + 19844
22 clang++                  0x0000000108784416
clang::Parser::ParseCastExpression(clang::Parser::CastParseKind, bool, bool&,
clang::Parser::TypeCastState, bool, bool*) + 8038
23 clang++                  0x000000010877ee09
clang::Parser::ParseCastExpression(clang::Parser::CastParseKind, bool,
clang::Parser::TypeCastState, bool, bool*) + 89
24 clang++                  0x000000010877d298
clang::Parser::ParseAssignmentExpression(clang::Parser::TypeCastState) + 280
25 clang++                  0x000000010877d14f
clang::Parser::ParseExpression(clang::Parser::TypeCastState) + 31
26 clang++                  0x000000010875c874
clang::Parser::ParseDecltypeSpecifier(clang::DeclSpec&) + 836
27 clang++                  0x00000001087926df
clang::Parser::ParseOptionalCXXScopeSpecifier(clang::CXXScopeSpec&,
clang::OpaquePtr<clang::QualType>, bool, bool, bool*, bool,
clang::IdentifierInfo**, bool, bool) + 1295
28 clang++                  0x0000000108826160
clang::Parser::TryAnnotateCXXScopeToken(bool) + 304
29 clang++                  0x000000010873ca94
clang::Parser::ParseDeclarationSpecifiers(clang::DeclSpec&,
clang::Parser::ParsedTemplateInfo const&, clang::AccessSpecifier,
clang::Parser::DeclSpecContext, clang::Parser::LateParsedAttrList*) + 4596
30 clang++                  0x0000000108765d1d
clang::Parser::ParseCXXClassMemberDeclaration(clang::AccessSpecifier,
clang::ParsedAttributes&, clang::Parser::ParsedTemplateInfo const&,
clang::ParsingDeclRAIIObject*) + 2781
31 clang++                  0x00000001087687da
clang::Parser::ParseCXXClassMemberDeclarationWithPragmas(clang::AccessSpecifier&,
clang::Parser::ParsedAttributesWithRange&, clang::TypeSpecifierType,
clang::Decl*) + 2122
32 clang++                  0x0000000108762c73
clang::Parser::ParseCXXMemberSpecification(clang::SourceLocation,
clang::SourceLocation, clang::Parser::ParsedAttributesWithRange&, unsigned int,
clang::Decl*) + 2963
33 clang++                  0x0000000108760b78
clang::Parser::ParseClassSpecifier(clang::tok::TokenKind,
clang::SourceLocation, clang::DeclSpec&, clang::Parser::ParsedTemplateInfo
const&, clang::AccessSpecifier, bool, clang::Parser::DeclSpecContext,
clang::Parser::ParsedAttributesWithRange&) + 9720
34 clang++                  0x000000010873f4c3
clang::Parser::ParseDeclarationSpecifiers(clang::DeclSpec&,
clang::Parser::ParsedTemplateInfo const&, clang::AccessSpecifier,
clang::Parser::DeclSpecContext, clang::Parser::LateParsedAttrList*) + 15395
35 clang++                  0x00000001088209d8
clang::Parser::ParseDeclOrFunctionDefInternal(clang::Parser::ParsedAttributesWithRange&,
clang::ParsingDeclSpec&, clang::AccessSpecifier) + 136
36 clang++                  0x0000000108820522
clang::Parser::ParseDeclarationOrFunctionDefinition(clang::Parser::ParsedAttributesWithRange&,
clang::ParsingDeclSpec*, clang::AccessSpecifier) + 194
37 clang++                  0x000000010881f61f
clang::Parser::ParseExternalDeclaration(clang::Parser::ParsedAttributesWithRange&,
clang::ParsingDeclSpec*) + 3551
38 clang++                  0x000000010881d6bb
clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&, bool)
+ 1739
39 clang++                  0x000000010881cf63
clang::Parser::ParseFirstTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&) +
51
40 clang++                  0x000000010872a53f clang::ParseAST(clang::Sema&,
bool, bool) + 415
41 clang++                  0x0000000105f70e8c
clang::ASTFrontendAction::ExecuteAction() + 300
42 clang++                  0x00000001058a955a
clang::CodeGenAction::ExecuteAction() + 90
43 clang++                  0x0000000105f704bc clang::FrontendAction::Execute()
+ 124
44 clang++                  0x0000000105e8a2e8
clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) + 920
45 clang++                  0x000000010607972e
clang::ExecuteCompilerInvocation(clang::CompilerInstance*) + 1614
46 clang++                  0x000000010143363d cc1_main(llvm::ArrayRef<char
const*>, char const*, void*) + 1501
47 clang++                  0x0000000101425e3b
ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&) + 427
48 clang++                  0x0000000105c414c5
clang::driver::CC1Command::Execute(llvm::ArrayRef<llvm::Optional<llvm::StringRef>
>, std::__1::basic_string<char, std::__1::char_traits<char>,
std::__1::allocator<char> >*, bool*) const::$_1::operator()() const + 37
49 clang++                  0x0000000105c41495 void llvm::function_ref<void
()>::callback_fn<clang::driver::CC1Command::Execute(llvm::ArrayRef<llvm::Optional<llvm::StringRef>
>, std::__1::basic_string<char, std::__1::char_traits<char>,
std::__1::allocator<char> >*, bool*) const::$_1>(long) + 21
50 clang++                  0x0000000104d799b9 llvm::function_ref<void
()>::operator()() const + 25
51 clang++                  0x0000000104d7995c
llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) + 236
52 clang++                  0x0000000105c3ff5c
clang::driver::CC1Command::Execute(llvm::ArrayRef<llvm::Optional<llvm::StringRef>
>, std::__1::basic_string<char, std::__1::char_traits<char>,
std::__1::allocator<char> >*, bool*) const + 524
53 clang++                  0x0000000105bea406
clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&,
clang::driver::Command const*&) const + 758
54 clang++                  0x0000000105bea6c8
clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&,
llvm::SmallVectorImpl<std::__1::pair<int, clang::driver::Command const*> >&)
const + 152
55 clang++                  0x0000000105c054f5
clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&,
llvm::SmallVectorImpl<std::__1::pair<int, clang::driver::Command const*> >&) +
325
56 clang++                  0x000000010142538b main + 3371
57 libdyld.dylib            0x00007fff695ba3d5 start + 1
clang-13: error: clang frontend command failed with exit code 134 (use -v to
see invocation)
clang version 13.0.0 (git at github.com:Quuxplusone/llvm-project
4adea96d9486bb19440243420ba234c1916907c9)
Target: x86_64-apple-darwin18.7.0
Thread model: posix
InstalledDir: /Users/aodwyer/llvm-project/build-debug/bin
clang-13: note: diagnostic msg: 
********************

PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
Preprocessed source(s) and associated run script(s) are located at:
clang-13: note: diagnostic msg:
/var/folders/0l/9t0yv2890_g4wgmy53n_mg7w0000gy/T/test-a31910.cpp
clang-13: note: diagnostic msg:
/var/folders/0l/9t0yv2890_g4wgmy53n_mg7w0000gy/T/test-a31910.sh
clang-13: note: diagnostic msg: Crash backtrace is located in
clang-13: note: diagnostic msg:
/Users/aodwyer/Library/Logs/DiagnosticReports/clang-13_<YYYY-MM-DD-HHMMSS>_<hostname>.crash
clang-13: note: diagnostic msg: (choose the .crash file that corresponds to
your crash)
clang-13: note: diagnostic msg: 

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

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20210328/7e4e4cfb/attachment-0001.html>


More information about the llvm-bugs mailing list