[llvm-bugs] [Bug 50150] New: "Could not emit constant value "abstractly"" on combination of non-type template parameter and function pointers.

via llvm-bugs llvm-bugs at lists.llvm.org
Wed Apr 28 03:05:40 PDT 2021


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

            Bug ID: 50150
           Summary: "Could not emit constant value "abstractly"" on
                    combination of non-type template parameter and
                    function pointers.
           Product: new-bugs
           Version: unspecified
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: new bugs
          Assignee: unassignedbugs at nondot.org
          Reporter: pariks at protonmail.com
                CC: htmldeveloper at gmail.com, llvm-bugs at lists.llvm.org

Created attachment 24807
  --> https://bugs.llvm.org/attachment.cgi?id=24807&action=edit
preprocessed source

The following code results in a segmentation fault when compiled with clang.

I've noticed several variations in the backtrace and some cases where a
backtrace isn't printed. Mostly with the change in the usage of the non-type
template parameter in function "a".

The issue doesn't happen with GCC or MSVC. Interestingly, it also doesn't
happen if the functions are moved outside of the scope of the class.

Compiled with clang 11.1.0 from the Arch Linux repositories, and
12.0.0/trunk/other versions on Godbolt. Was able to reproduce the crash in all
the cases. 




Backtrace:

test.cpp:14:19: error: internal error: could not emit constant value
"abstractly"
        b ((void*)i, s_func, c<s_func>);
                  ^
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: clang++ -c test.cpp -std=c++17 
1.      <eof> parser at end of file
2.      Per-file LLVM IR generation
3.      test.cpp:10:17: Generating code for declaration 'CrashClass::a'
 #0 0x00007f36e04df0db llvm::sys::PrintStackTrace(llvm::raw_ostream&)
(/usr/bin/../lib/libLLVM-11.so+0xa760db)
 #1 0x00007f36e04dce14 llvm::sys::RunSignalHandlers()
(/usr/bin/../lib/libLLVM-11.so+0xa73e14)
 #2 0x00007f36e03ef659 (/usr/bin/../lib/libLLVM-11.so+0x986659)
 #3 0x00007f36df6fbf80 __restore_rt (/usr/bin/../lib/libc.so.6+0x3cf80)
 #4 0x00007f36e6f789a0
clang::CodeGen::CGOpenCLRuntime::getSamplerType(clang::Type const*)
(/usr/bin/../lib/libclang-cpp.so.11.1+0x1ab09a0)
 #5 0x00007f36e70c49af
clang::CodeGen::CodeGenModule::createOpenCLIntToSamplerConversion(clang::Expr
const*, clang::CodeGen::CodeGenFunction&)
(/usr/bin/../lib/libclang-cpp.so.11.1+0x1bfc9af)
 #6 0x00007f36e6ef7803 (/usr/bin/../lib/libclang-cpp.so.11.1+0x1a2f803)
 #7 0x00007f36e6ef9723
clang::CodeGen::CodeGenFunction::EmitScalarExpr(clang::Expr const*, bool)
(/usr/bin/../lib/libclang-cpp.so.11.1+0x1a31723)
 #8 0x00007f36e6e8bb28 clang::CodeGen::CodeGenFunction::EmitAnyExpr(clang::Expr
const*, clang::CodeGen::AggValueSlot, bool)
(/usr/bin/../lib/libclang-cpp.so.11.1+0x19c3b28)
 #9 0x00007f36e6e8bca1
clang::CodeGen::CodeGenFunction::EmitAnyExprToTemp(clang::Expr const*)
(/usr/bin/../lib/libclang-cpp.so.11.1+0x19c3ca1)
#10 0x00007f36e6e10762
clang::CodeGen::CodeGenFunction::EmitCallArg(clang::CodeGen::CallArgList&,
clang::Expr const*, clang::QualType)
(/usr/bin/../lib/libclang-cpp.so.11.1+0x1948762)
#11 0x00007f36e6e11c30
clang::CodeGen::CodeGenFunction::EmitCallArgs(clang::CodeGen::CallArgList&,
llvm::ArrayRef<clang::QualType>,
llvm::iterator_range<clang::Stmt::CastIterator<clang::Expr, clang::Expr const*
const, clang::Stmt const* const> >,
clang::CodeGen::CodeGenFunction::AbstractCallee, unsigned int,
clang::CodeGen::CodeGenFunction::EvaluationOrder)
(/usr/bin/../lib/libclang-cpp.so.11.1+0x1949c30)
#12 0x00007f36e6e9bb82
clang::CodeGen::CodeGenFunction::EmitCall(clang::QualType,
clang::CodeGen::CGCallee const&, clang::CallExpr const*,
clang::CodeGen::ReturnValueSlot, llvm::Value*)
(/usr/bin/../lib/libclang-cpp.so.11.1+0x19d3b82)
#13 0x00007f36e6ea9c40
clang::CodeGen::CodeGenFunction::EmitCallExpr(clang::CallExpr const*,
clang::CodeGen::ReturnValueSlot)
(/usr/bin/../lib/libclang-cpp.so.11.1+0x19e1c40)
#14 0x00007f36e6efc21d (/usr/bin/../lib/libclang-cpp.so.11.1+0x1a3421d)
#15 0x00007f36e6ef9723
clang::CodeGen::CodeGenFunction::EmitScalarExpr(clang::Expr const*, bool)
(/usr/bin/../lib/libclang-cpp.so.11.1+0x1a31723)
#16 0x00007f36e6e8bb28 clang::CodeGen::CodeGenFunction::EmitAnyExpr(clang::Expr
const*, clang::CodeGen::AggValueSlot, bool)
(/usr/bin/../lib/libclang-cpp.so.11.1+0x19c3b28)
#17 0x00007f36e6ea0d47
clang::CodeGen::CodeGenFunction::EmitIgnoredExpr(clang::Expr const*)
(/usr/bin/../lib/libclang-cpp.so.11.1+0x19d8d47)
#18 0x00007f36e7015e8b clang::CodeGen::CodeGenFunction::EmitStmt(clang::Stmt
const*, llvm::ArrayRef<clang::Attr const*>)
(/usr/bin/../lib/libclang-cpp.so.11.1+0x1b4de8b)
#19 0x00007f36e7016edb
clang::CodeGen::CodeGenFunction::EmitCompoundStmtWithoutScope(clang::CompoundStmt
const&, bool, clang::CodeGen::AggValueSlot)
(/usr/bin/../lib/libclang-cpp.so.11.1+0x1b4eedb)
#20 0x00007f36e707de42
clang::CodeGen::CodeGenFunction::EmitFunctionBody(clang::Stmt const*)
(/usr/bin/../lib/libclang-cpp.so.11.1+0x1bb5e42)
#21 0x00007f36e70896d4
clang::CodeGen::CodeGenFunction::GenerateCode(clang::GlobalDecl,
llvm::Function*, clang::CodeGen::CGFunctionInfo const&)
(/usr/bin/../lib/libclang-cpp.so.11.1+0x1bc16d4)
#22 0x00007f36e70c27a7
clang::CodeGen::CodeGenModule::EmitGlobalFunctionDefinition(clang::GlobalDecl,
llvm::GlobalValue*) (/usr/bin/../lib/libclang-cpp.so.11.1+0x1bfa7a7)
#23 0x00007f36e70becb4
clang::CodeGen::CodeGenModule::EmitGlobalDefinition(clang::GlobalDecl,
llvm::GlobalValue*) (/usr/bin/../lib/libclang-cpp.so.11.1+0x1bf6cb4)
#24 0x00007f36e70c793c clang::CodeGen::CodeGenModule::EmitDeferred()
(/usr/bin/../lib/libclang-cpp.so.11.1+0x1bff93c)
#25 0x00007f36e70c7954 clang::CodeGen::CodeGenModule::EmitDeferred()
(/usr/bin/../lib/libclang-cpp.so.11.1+0x1bff954)
#26 0x00007f36e70c7954 clang::CodeGen::CodeGenModule::EmitDeferred()
(/usr/bin/../lib/libclang-cpp.so.11.1+0x1bff954)
#27 0x00007f36e70c7954 clang::CodeGen::CodeGenModule::EmitDeferred()
(/usr/bin/../lib/libclang-cpp.so.11.1+0x1bff954)
#28 0x00007f36e70c7954 clang::CodeGen::CodeGenModule::EmitDeferred()
(/usr/bin/../lib/libclang-cpp.so.11.1+0x1bff954)
#29 0x00007f36e70c7a2b clang::CodeGen::CodeGenModule::Release()
(/usr/bin/../lib/libclang-cpp.so.11.1+0x1bffa2b)
#30 0x00007f36e71351eb (/usr/bin/../lib/libclang-cpp.so.11.1+0x1c6d1eb)
#31 0x00007f36e7075765 (/usr/bin/../lib/libclang-cpp.so.11.1+0x1bad765)
#32 0x00007f36e5e26ec9 clang::ParseAST(clang::Sema&, bool, bool)
(/usr/bin/../lib/libclang-cpp.so.11.1+0x95eec9)
#33 0x00007f36e77abc89 clang::FrontendAction::Execute()
(/usr/bin/../lib/libclang-cpp.so.11.1+0x22e3c89)
#34 0x00007f36e775b6ce
clang::CompilerInstance::ExecuteAction(clang::FrontendAction&)
(/usr/bin/../lib/libclang-cpp.so.11.1+0x22936ce)
#35 0x00007f36e78295cd
clang::ExecuteCompilerInvocation(clang::CompilerInstance*)
(/usr/bin/../lib/libclang-cpp.so.11.1+0x23615cd)
#36 0x000055c39da06852 cc1_main(llvm::ArrayRef<char const*>, char const*,
void*) (/usr/bin/clang-11+0x12852)
#37 0x000055c39da03dfc (/usr/bin/clang-11+0xfdfc)
#38 0x00007f36e7426a65 (/usr/bin/../lib/libclang-cpp.so.11.1+0x1f5ea65)
#39 0x00007f36e03ef773
llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>)
(/usr/bin/../lib/libLLVM-11.so+0x986773)
#40 0x00007f36e742770e (/usr/bin/../lib/libclang-cpp.so.11.1+0x1f5f70e)
#41 0x00007f36e73fcf78
clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&,
clang::driver::Command const*&) const
(/usr/bin/../lib/libclang-cpp.so.11.1+0x1f34f78)
#42 0x00007f36e73fd867
clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&,
llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*> >&) const
(/usr/bin/../lib/libclang-cpp.so.11.1+0x1f35867)
#43 0x00007f36e740934c
clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&,
llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*> >&)
(/usr/bin/../lib/libclang-cpp.so.11.1+0x1f4134c)
#44 0x000055c39da01c02 main (/usr/bin/clang-11+0xdc02)
#45 0x00007f36df6e6b25 __libc_start_main (/usr/bin/../lib/libc.so.6+0x27b25)
#46 0x000055c39da0376e _start (/usr/bin/clang-11+0xf76e)
clang-11: error: clang frontend command failed due to signal (use -v to see
invocation)
clang version 11.1.0
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin
clang-11: note: diagnostic msg: 
********************

PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
Preprocessed source(s) and associated run script(s) are located at:
clang-11: note: diagnostic msg: /tmp/test-b35c7a.cpp
clang-11: note: diagnostic msg: /tmp/test-b35c7a.sh
clang-11: 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/20210428/25e6d8c7/attachment-0001.html>


More information about the llvm-bugs mailing list