[llvm-bugs] [Bug 50756] New: delayed template parsing asserts on invalid constructor

via llvm-bugs llvm-bugs at lists.llvm.org
Thu Jun 17 09:01:36 PDT 2021


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

            Bug ID: 50756
           Summary: delayed template parsing asserts on invalid
                    constructor
           Product: clang
           Version: trunk
          Hardware: PC
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++
          Assignee: unassignedclangbugs at nondot.org
          Reporter: erich.keane at intel.com
                CC: blitzrakete at gmail.com, dgregor at apple.com,
                    erik.pilkington at gmail.com, llvm-bugs at lists.llvm.org,
                    richard-llvm at metafoo.co.uk

I did a bit of digging, and it appears that the late-template-parsing happens,
but seems to not handle the error case and continues on.  The late-parsing
results in no-body due to the error (I believe?), and thus the assert.

bash-4.2$ cat bug.cpp
class simd_storage {
  float __storage_;
};


template <class _Tp>
struct simd {
  simd_storage __s_;
  simd(const float &__raw_simd) : __s_.__storage_(__raw_simd) {}
};

simd<float> SIMD_CALLEE() {
  float data;
  return simd<float>{ data };
}
bash-4.2$  ./bin/clang -cc1 bug.cpp -fdelayed-template-parsing
bug.cpp:9:39: error: expected '(' or '{'
  simd(const float &__raw_simd) : __s_.__storage_(__raw_simd) {}
                                      ^
bug.cpp:9:39: error: expected member name or ';' after declaration specifiers
bug.cpp:15:2: error: expected '(' or '{'
}
 ^
clang:
/iusers/ekeane1/workspaces/llvm-project/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp:4871:
void clang::Sema::InstantiateFunctionDefinition(clang::SourceLocation,
clang::FunctionDecl*, bool, bool, bool): Assertion `(Pattern ||
PatternDecl->isDefaulted() || PatternDecl->hasSkippedBody()) && "unexpected
kind of function template definition"' failed.
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: ./bin/clang -cc1 bug.cpp -fdelayed-template-parsing
1.      <eof> parser at end of file
 #0 0x000000000548e1cb llvm::sys::PrintStackTrace(llvm::raw_ostream&, int)
/iusers/ekeane1/workspaces/llvm-project/llvm/lib/Support/Unix/Signals.inc:565:22
 #1 0x000000000548e282 PrintStackTraceSignalHandler(void*)
/iusers/ekeane1/workspaces/llvm-project/llvm/lib/Support/Unix/Signals.inc:632:1
 #2 0x000000000548c23f llvm::sys::RunSignalHandlers()
/iusers/ekeane1/workspaces/llvm-project/llvm/lib/Support/Signals.cpp:76:20
 #3 0x000000000548dc13 SignalHandler(int)
/iusers/ekeane1/workspaces/llvm-project/llvm/lib/Support/Unix/Signals.inc:407:1
 #4 0x00007febb46995e0 __restore_rt sigaction.c:0:0
 #5 0x00007febb32121f7 raise (/lib64/libc.so.6+0x351f7)
 #6 0x00007febb32138e8 abort (/lib64/libc.so.6+0x368e8)
 #7 0x00007febb320b266 __assert_fail_base (/lib64/libc.so.6+0x2e266)
 #8 0x00007febb320b312 (/lib64/libc.so.6+0x2e312)
 #9 0x00000000091b965d
clang::Sema::InstantiateFunctionDefinition(clang::SourceLocation,
clang::FunctionDecl*, bool, bool, bool)
/iusers/ekeane1/workspaces/llvm-project/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp:4869:3
#10 0x00000000091bdef0 clang::Sema::PerformPendingInstantiations(bool)
/iusers/ekeane1/workspaces/llvm-project/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp:6210:32
#11 0x00000000085379a7
clang::Sema::ActOnEndOfTranslationUnitFragment(clang::Sema::TUFragmentKind)
/iusers/ekeane1/workspaces/llvm-project/clang/lib/Sema/Sema.cpp:1012:66
#12 0x0000000008537c03 clang::Sema::ActOnEndOfTranslationUnit()
/iusers/ekeane1/workspaces/llvm-project/clang/lib/Sema/Sema.cpp:1055:9
#13 0x00000000083e7d69
clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&, bool)
/iusers/ekeane1/workspaces/llvm-project/clang/lib/Parse/Parser.cpp:695:12
#14 0x00000000083e3575 clang::ParseAST(clang::Sema&, bool, bool)
/iusers/ekeane1/workspaces/llvm-project/clang/lib/Parse/ParseAST.cpp:158:37
#15 0x000000000612c1ed clang::ASTFrontendAction::ExecuteAction()
/iusers/ekeane1/workspaces/llvm-project/clang/lib/Frontend/FrontendAction.cpp:1058:11
#16 0x000000000612bb19 clang::FrontendAction::Execute()
/iusers/ekeane1/workspaces/llvm-project/clang/lib/Frontend/FrontendAction.cpp:955:38
#17 0x000000000607636b
clang::CompilerInstance::ExecuteAction(clang::FrontendAction&)
/iusers/ekeane1/workspaces/llvm-project/clang/lib/Frontend/CompilerInstance.cpp:977:42
#18 0x00000000062ab7e4
clang::ExecuteCompilerInvocation(clang::CompilerInstance*)
/iusers/ekeane1/workspaces/llvm-project/clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp:278:38
#19 0x00000000025a0d29 cc1_main(llvm::ArrayRef<char const*>, char const*,
void*)
/iusers/ekeane1/workspaces/llvm-project/clang/tools/driver/cc1_main.cpp:246:40
#20 0x0000000002595e05 ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&)
/iusers/ekeane1/workspaces/llvm-project/clang/tools/driver/driver.cpp:338:20
#21 0x00000000025964d3 main
/iusers/ekeane1/workspaces/llvm-project/clang/tools/driver/driver.cpp:415:26
#22 0x00007febb31fec05 __libc_start_main (/lib64/libc.so.6+0x21c05)
#23 0x0000000002594679 _start (./bin/clang+0x2594679)
Aborted (core dumped)

-- 
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/20210617/0d01f372/attachment.html>


More information about the llvm-bugs mailing list