[llvm-bugs] [Bug 42587] New: ICE on missing ... of operator sizeof... at trailing return type for lambda

via llvm-bugs llvm-bugs at lists.llvm.org
Thu Jul 11 09:05:41 PDT 2019


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

            Bug ID: 42587
           Summary: ICE on missing ... of operator sizeof... at trailing
                    return type for lambda
           Product: new-bugs
           Version: 6.0
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: new bugs
          Assignee: unassignedbugs at nondot.org
          Reporter: agate.pris at gmail.com
                CC: htmldeveloper at gmail.com, llvm-bugs at lists.llvm.org

clang++ crash with segmentation fault if ... of operator sizeof... forgotten at
trailing return type of lambda.

template < int > class ct {};
int main() {
    [](auto... args) -> ct< sizeof(args) >{}();
}

https://wandbox.org/permlink/yW6TCpJqvqTx0EKw

This is regression from clang 6.0.0. I confirmed that it also occurs at 6.0.1,
7.0.0, 8.0.0 and 9.0.0.

clang 5.0.0 produces the following expected error message:

prog.cc:8:5: error: expected expression
    [](auto... args) -> ct< sizeof(args) >{}();

Here is valid code. (This code produce an warning.)

template < int > class ct {};
int main() {
    [](auto... args) -> ct< sizeof...(args) >{}();
}

Also, the following code replaces the lambda of the above program with a
function template. This program correctly outputs an expected error.

template < int > class ct {};
template < typename... Args >
auto ft(Args... args) -> ct< sizeof(args) > {}
int main() {
    ft();
}

Stack dump:
0.      Program arguments: /opt/wandbox/clang-head/bin/clang-9 -cc1 -triple
x86_64-unknown-linux-gnu -emit-obj -mrelax-all -disable-free
-disable-llvm-verifier -discard-value-names -main-file-name prog.cc
-mrelocation-model static -mthread-model posix -mdisable-fp-elim -fmath-errno
-masm-verbose -mconstructor-aliases -munwind-tables -fuse-init-array
-target-cpu x86-64 -dwarf-column-info -debugger-tuning=gdb -nostdinc++
-resource-dir /opt/wandbox/clang-head/lib/clang/9.0.0 -I
/opt/wandbox/clang-head/include/c++/v1 -I /opt/wandbox/boost-sml/include -I
/opt/wandbox/boost-di/include -I /opt/wandbox/range-v3/include -I
/opt/wandbox/nlohmann-json/src -I /opt/wandbox/cmcstl2/include -I
/opt/wandbox/te/include -internal-isystem /usr/local/include -internal-isystem
/opt/wandbox/clang-head/lib/clang/9.0.0/include -internal-externc-isystem
/usr/include/x86_64-linux-gnu -internal-externc-isystem /include
-internal-externc-isystem /usr/include -fdeprecated-macro
-fdebug-compilation-dir /home/jail -ferror-limit 19 -fmessage-length 0
-fobjc-runtime=gcc -fcxx-exceptions -fexceptions -fdiagnostics-show-option
-fcolor-diagnostics -fansi-escape-codes -faddrsig -o /tmp/prog-a3a167.o -x c++
prog.cc 
1.      <eof> parser at end of file
2.      prog.cc:2:5: LLVM IR generation of declaration 'main'
3.      prog.cc:2:5: Generating code for declaration 'main'
 #0 0x0000000001fe2294 PrintStackTraceSignalHandler(void*)
(/opt/wandbox/clang-head/bin/clang-9+0x1fe2294)
 #1 0x0000000001fe01e0 llvm::sys::RunSignalHandlers()
(/opt/wandbox/clang-head/bin/clang-9+0x1fe01e0)
 #2 0x0000000001fe2698 SignalHandler(int)
(/opt/wandbox/clang-head/bin/clang-9+0x1fe2698)
 #3 0x00007fce1652c390 __restore_rt
(/lib/x86_64-linux-gnu/libpthread.so.0+0x11390)
 #4 0x0000000001b1cf4a llvm::FunctionType::get(llvm::Type*,
llvm::ArrayRef<llvm::Type*>, bool)
(/opt/wandbox/clang-head/bin/clang-9+0x1b1cf4a)
 #5 0x000000000232293f
clang::CodeGen::CodeGenTypes::GetFunctionType(clang::CodeGen::CGFunctionInfo
const&) (/opt/wandbox/clang-head/bin/clang-9+0x232293f)
 #6 0x0000000002386d4b
clang::CodeGen::CodeGenFunction::EmitCXXMemberOrOperatorMemberCallExpr(clang::CallExpr
const*, clang::CXXMethodDecl const*, clang::CodeGen::ReturnValueSlot, bool,
clang::NestedNameSpecifier*, bool, clang::Expr const*)
(/opt/wandbox/clang-head/bin/clang-9+0x2386d4b)
 #7 0x00000000023879f8
clang::CodeGen::CodeGenFunction::EmitCXXOperatorMemberCallExpr(clang::CXXOperatorCallExpr
const*, clang::CXXMethodDecl const*, clang::CodeGen::ReturnValueSlot)
(/opt/wandbox/clang-head/bin/clang-9+0x23879f8)
 #8 0x0000000002378764
clang::CodeGen::CodeGenFunction::EmitCallExpr(clang::CallExpr const*,
clang::CodeGen::ReturnValueSlot)
(/opt/wandbox/clang-head/bin/clang-9+0x2378764)
 #9 0x00000000023a8344 (anonymous
namespace)::ScalarExprEmitter::VisitCallExpr(clang::CallExpr const*)
(/opt/wandbox/clang-head/bin/clang-9+0x23a8344)
#10 0x00000000023a2960 clang::StmtVisitorBase<std::add_pointer, (anonymous
namespace)::ScalarExprEmitter, llvm::Value*>::Visit(clang::Stmt*)
(/opt/wandbox/clang-head/bin/clang-9+0x23a2960)
#11 0x0000000002396b12
clang::CodeGen::CodeGenFunction::EmitScalarExpr(clang::Expr const*, bool)
(/opt/wandbox/clang-head/bin/clang-9+0x2396b12)
#12 0x000000000235f553 clang::CodeGen::CodeGenFunction::EmitAnyExpr(clang::Expr
const*, clang::CodeGen::AggValueSlot, bool)
(/opt/wandbox/clang-head/bin/clang-9+0x235f553)
#13 0x000000000235f4a9
clang::CodeGen::CodeGenFunction::EmitIgnoredExpr(clang::Expr const*)
(/opt/wandbox/clang-head/bin/clang-9+0x235f4a9)
#14 0x00000000021b2587 clang::CodeGen::CodeGenFunction::EmitStmt(clang::Stmt
const*, llvm::ArrayRef<clang::Attr const*>)
(/opt/wandbox/clang-head/bin/clang-9+0x21b2587)
#15 0x00000000021bb92f
clang::CodeGen::CodeGenFunction::EmitCompoundStmtWithoutScope(clang::CompoundStmt
const&, bool, clang::CodeGen::AggValueSlot)
(/opt/wandbox/clang-head/bin/clang-9+0x21bb92f)
#16 0x00000000021f8b10
clang::CodeGen::CodeGenFunction::EmitFunctionBody(clang::Stmt const*)
(/opt/wandbox/clang-head/bin/clang-9+0x21f8b10)
#17 0x00000000021f93b1
clang::CodeGen::CodeGenFunction::GenerateCode(clang::GlobalDecl,
llvm::Function*, clang::CodeGen::CGFunctionInfo const&)
(/opt/wandbox/clang-head/bin/clang-9+0x21f93b1)
#18 0x00000000022128c2
clang::CodeGen::CodeGenModule::EmitGlobalFunctionDefinition(clang::GlobalDecl,
llvm::GlobalValue*) (/opt/wandbox/clang-head/bin/clang-9+0x22128c2)
#19 0x000000000220c878
clang::CodeGen::CodeGenModule::EmitGlobalDefinition(clang::GlobalDecl,
llvm::GlobalValue*) (/opt/wandbox/clang-head/bin/clang-9+0x220c878)
#20 0x0000000002215056
clang::CodeGen::CodeGenModule::EmitTopLevelDecl(clang::Decl*)
(/opt/wandbox/clang-head/bin/clang-9+0x2215056)
#21 0x0000000002b3460f (anonymous
namespace)::CodeGeneratorImpl::HandleTopLevelDecl(clang::DeclGroupRef)
(/opt/wandbox/clang-head/bin/clang-9+0x2b3460f)
#22 0x0000000002b31903
clang::BackendConsumer::HandleTopLevelDecl(clang::DeclGroupRef)
(/opt/wandbox/clang-head/bin/clang-9+0x2b31903)
#23 0x000000000334fb13 clang::ParseAST(clang::Sema&, bool, bool)
(/opt/wandbox/clang-head/bin/clang-9+0x334fb13)
#24 0x00000000025f850f clang::FrontendAction::Execute()
(/opt/wandbox/clang-head/bin/clang-9+0x25f850f)
#25 0x00000000025b18c8
clang::CompilerInstance::ExecuteAction(clang::FrontendAction&)
(/opt/wandbox/clang-head/bin/clang-9+0x25b18c8)
#26 0x00000000026aa803
clang::ExecuteCompilerInvocation(clang::CompilerInstance*)
(/opt/wandbox/clang-head/bin/clang-9+0x26aa803)
#27 0x0000000000924f8b cc1_main(llvm::ArrayRef<char const*>, char const*,
void*) (/opt/wandbox/clang-head/bin/clang-9+0x924f8b)
#28 0x00000000009239c0 main (/opt/wandbox/clang-head/bin/clang-9+0x9239c0)
#29 0x00007fce1529b830 __libc_start_main
(/lib/x86_64-linux-gnu/libc.so.6+0x20830)
#30 0x0000000000920b89 _start (/opt/wandbox/clang-head/bin/clang-9+0x920b89)
clang-9: error: unable to execute command: Segmentation fault
clang-9: error: clang frontend command failed due to signal (use -v to see
invocation)
clang version 9.0.0 (https://github.com/llvm-mirror/clang.git
d9f9d6531f3c8c8ce22b63989cdeaeb220f0f36a)
(https://github.com/llvm-mirror/llvm.git
e3fd2a343a10616bd1d7e010c32c675fc934802e)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /opt/wandbox/clang-head/bin
clang-9: note: diagnostic msg: PLEASE submit a bug report to
https://bugs.llvm.org/ and include the crash backtrace, preprocessed source,
and associated run script.
clang-9: note: diagnostic msg: 
********************

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

********************
254

-- 
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/20190711/a1288362/attachment-0001.html>


More information about the llvm-bugs mailing list