[llvm-bugs] [Bug 51828] New: ICE with member pointer to specialized template in MSVC ABI
via llvm-bugs
llvm-bugs at lists.llvm.org
Sun Sep 12 11:37:40 PDT 2021
https://bugs.llvm.org/show_bug.cgi?id=51828
Bug ID: 51828
Summary: ICE with member pointer to specialized template in
MSVC ABI
Product: new-bugs
Version: trunk
Hardware: PC
OS: Linux
Status: NEW
Severity: enhancement
Priority: P
Component: new bugs
Assignee: unassignedbugs at nondot.org
Reporter: blubban at gmail.com
CC: htmldeveloper at gmail.com, llvm-bugs at lists.llvm.org
template<int> class A;
constexpr void h()
{
int A<5>::* x = 0;
}
template<> class A<5> {};
void h2() { h(); }
Compile with --target=x86_64-pc-windows-msvc. Changing to consteval instead
makes Clang error out about that being a non-literal type, but still only on
MSVC ABI. MSVC itself accepts it.
Compiler Explorer: https://godbolt.org/z/aqW1dsxz1
A related input of interest is
template<int> class A;
template<typename T> constexpr int h()
{
return sizeof(int T::*);
}
int h2() { return h<A<5>>(); }
template<int> class A {};
which returns 12 on Clang, but 4 on MSVC. https://godbolt.org/z/Tdd761W4P
Both of the above are severe abuses of the C++ language, of course; I found
them while messing around with MSVC ABI sizeof member pointer being variable,
trying to make an object whose sizeof is 12 if it's 4 and 4 if it's 12. ICE is
the answer I deserve, but it begs me to report it, so here you go. For the
latter, I don't know if it's a Clang bug, MSVC bug, or nonsense where the
correct answer is WONTFIX.
Full output of the ICE:
clang-14: warning: argument unused during compilation:
'--gcc-toolchain=/opt/compiler-explorer/gcc-snapshot'
[-Wunused-command-line-argument]
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: /opt/compiler-explorer/clang-trunk/bin/clang++ -g -o
/app/output.s -mllvm --x86-asm-syntax=intel -S
--gcc-toolchain=/opt/compiler-explorer/gcc-snapshot -fcolor-diagnostics
-fno-crash-diagnostics --target=x86_64-pc-windows-msvc <source>
1. <eof> parser at end of file
2. Per-file LLVM IR generation
3. <source>:3:16: Generating code for declaration 'h'
#0 0x00005642f0b8684f PrintStackTraceSignalHandler(void*) Signals.cpp:0:0
#1 0x00005642f0b84710 llvm::sys::CleanupOnSignal(unsigned long)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x3584710)
#2 0x00005642f0ad5088 CrashRecoverySignalHandler(int)
CrashRecoveryContext.cpp:0:0
#3 0x00007f25dc4cd3c0 __restore_rt
(/lib/x86_64-linux-gnu/libpthread.so.0+0x153c0)
#4 0x00005642f345b7d0 clang::MSInheritanceAttr::getSemanticSpelling() const
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x5e5b7d0)
#5 0x00005642f0fca034 (anonymous
namespace)::MicrosoftCXXABI::GetNullMemberPointerFields(clang::MemberPointerType
const*, llvm::SmallVectorImpl<llvm::Constant*>&) MicrosoftCXXABI.cpp:0:0
#6 0x00005642f0fca19a (anonymous
namespace)::MicrosoftCXXABI::EmitNullMemberPointer(clang::MemberPointerType
const*) MicrosoftCXXABI.cpp:0:0
#7 0x00005642f11c14db (anonymous
namespace)::ScalarExprEmitter::VisitCastExpr(clang::CastExpr*)
CGExprScalar.cpp:0:0
#8 0x00005642f11ba933 (anonymous
namespace)::ScalarExprEmitter::Visit(clang::Expr*) CGExprScalar.cpp:0:0
#9 0x00005642f11bc413
clang::CodeGen::CodeGenFunction::EmitScalarExpr(clang::Expr const*, bool)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x3bbc413)
#10 0x00005642f114fadf
clang::CodeGen::CodeGenFunction::EmitScalarInit(clang::Expr const*,
clang::ValueDecl const*, clang::CodeGen::LValue, bool)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x3b4fadf)
#11 0x00005642f115049e
clang::CodeGen::CodeGenFunction::EmitExprAsInit(clang::Expr const*,
clang::ValueDecl const*, clang::CodeGen::LValue, bool)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x3b5049e)
#12 0x00005642f115671e
clang::CodeGen::CodeGenFunction::EmitAutoVarInit(clang::CodeGen::CodeGenFunction::AutoVarEmission
const&) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x3b5671e)
#13 0x00005642f11577c5
clang::CodeGen::CodeGenFunction::EmitVarDecl(clang::VarDecl const&)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x3b577c5)
#14 0x00005642f1157abd clang::CodeGen::CodeGenFunction::EmitDecl(clang::Decl
const&) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x3b57abd)
#15 0x00005642f0ebca57
clang::CodeGen::CodeGenFunction::EmitDeclStmt(clang::DeclStmt const&)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x38bca57)
#16 0x00005642f0ecc785
clang::CodeGen::CodeGenFunction::EmitSimpleStmt(clang::Stmt const*,
llvm::ArrayRef<clang::Attr const*>)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x38cc785)
#17 0x00005642f0ec6da2 clang::CodeGen::CodeGenFunction::EmitStmt(clang::Stmt
const*, llvm::ArrayRef<clang::Attr const*>)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x38c6da2)
#18 0x00005642f0ecc29c
clang::CodeGen::CodeGenFunction::EmitCompoundStmtWithoutScope(clang::CompoundStmt
const&, bool, clang::CodeGen::AggValueSlot)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x38cc29c)
#19 0x00005642f0f19fb9
clang::CodeGen::CodeGenFunction::EmitFunctionBody(clang::Stmt const*)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x3919fb9)
#20 0x00005642f0f229b5
clang::CodeGen::CodeGenFunction::GenerateCode(clang::GlobalDecl,
llvm::Function*, clang::CodeGen::CGFunctionInfo const&)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x39229b5)
#21 0x00005642f0f6802e
clang::CodeGen::CodeGenModule::EmitGlobalFunctionDefinition(clang::GlobalDecl,
llvm::GlobalValue*) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x396802e)
#22 0x00005642f0f64e25
clang::CodeGen::CodeGenModule::EmitGlobalDefinition(clang::GlobalDecl,
llvm::GlobalValue*) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x3964e25)
#23 0x00005642f0f6bb13 clang::CodeGen::CodeGenModule::EmitDeferred()
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x396bb13)
#24 0x00005642f0f6c8dc clang::CodeGen::CodeGenModule::Release()
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x396c8dc)
#25 0x00005642f1af87b7 (anonymous
namespace)::CodeGeneratorImpl::HandleTranslationUnit(clang::ASTContext&)
ModuleBuilder.cpp:0:0
#26 0x00005642f1af65fd
clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x44f65fd)
#27 0x00005642f29475c9 clang::ParseAST(clang::Sema&, bool, bool)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x53475c9)
#28 0x00005642f1af69d2 clang::CodeGenAction::ExecuteAction()
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x44f69d2)
#29 0x00005642f14942b1 clang::FrontendAction::Execute()
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x3e942b1)
#30 0x00005642f1431612
clang::CompilerInstance::ExecuteAction(clang::FrontendAction&)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x3e31612)
#31 0x00005642f15615b3
clang::ExecuteCompilerInvocation(clang::CompilerInstance*)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x3f615b3)
#32 0x00005642ee8ce67c cc1_main(llvm::ArrayRef<char const*>, char const*,
void*) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x12ce67c)
#33 0x00005642ee8ca6fd ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&)
driver.cpp:0:0
#34 0x00005642f12d8d65 void llvm::function_ref<void
()>::callback_fn<clang::driver::CC1Command::Execute(llvm::ArrayRef<llvm::Optional<llvm::StringRef>
>, std::__cxx11::basic_string<char, std::char_traits<char>,
std::allocator<char> >*, bool*) const::'lambda'()>(long) Job.cpp:0:0
#35 0x00005642f0ad5673
llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x34d5673)
#36 0x00005642f12dae1e
clang::driver::CC1Command::Execute(llvm::ArrayRef<llvm::Optional<llvm::StringRef>
>, std::__cxx11::basic_string<char, std::char_traits<char>,
std::allocator<char> >*, bool*) const
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x3cdae1e)
#37 0x00005642f12b075a
clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&,
clang::driver::Command const*&) const
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x3cb075a)
#38 0x00005642f12b129f
clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&,
llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*> >&) const
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x3cb129f)
#39 0x00005642f12ba785
clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&,
llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*> >&)
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x3cba785)
#40 0x00005642ee7deb2e main
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x11deb2e)
#41 0x00007f25dbf7d0b3 __libc_start_main
(/lib/x86_64-linux-gnu/libc.so.6+0x270b3)
#42 0x00005642ee8ca27a _start
(/opt/compiler-explorer/clang-trunk/bin/clang+++0x12ca27a)
clang-14: error: clang frontend command failed with exit code 139 (use -v to
see invocation)
Compiler returned: 139
--
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/20210912/8281c983/attachment.html>
More information about the llvm-bugs
mailing list