LLVM Bugzilla is read-only and represents the historical archive of all LLVM issues filled before November 26, 2021. Use github to submit LLVM bugs

Bug 18260 - Attempting to call member func named 'move' crashes the compiler if using -Weverything
Summary: Attempting to call member func named 'move' crashes the compiler if using -We...
Status: RESOLVED FIXED
Alias: None
Product: clang
Classification: Unclassified
Component: C++ (show other bugs)
Version: trunk
Hardware: PC Linux
: P normal
Assignee: Unassigned Clang Bugs
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-12-16 04:08 PST by Jesper Juhl
Modified: 2013-12-16 15:43 PST (History)
7 users (show)

See Also:
Fixed By Commit(s):


Attachments
test case to reproduce crash (72 bytes, text/plain)
2013-12-16 04:08 PST, Jesper Juhl
Details
preprocessed source for reproduce test case (109 bytes, text/x-c++src)
2013-12-16 04:09 PST, Jesper Juhl
Details
run script for reproduce test case (503 bytes, application/x-shellscript)
2013-12-16 04:09 PST, Jesper Juhl
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Jesper Juhl 2013-12-16 04:08:15 PST
Created attachment 11737 [details]
test case to reproduce crash

If I have a class/struct with a member named 'move()' and a function that attempts to call it (doesn't matter if it's through a pointer or reference), then the code will build and run fine unless I attempt to build with "-Weverything" - then the compiler crashes.

$ clang++ --version
clang version 3.5 (trunk 197368)
Target: x86_64-unknown-linux-gnu
Thread model: posix
$ cat ./move.cc 
struct A
{
    void move() {}
};

int main()
{
    A a;
    a.move();
}
$ clang++ ./move.cc 
$ echo $?
0
$ clang++ -Weverything ./move.cc 
clang: /home/jj/src/llvm/tools/clang/lib/Analysis/../../include/clang/AST/Expr.h:2194: const clang::Expr *clang::CallExpr::getArg(unsigned int) const: Assertion `Arg < NumArgs && "Arg access out of range!"' failed.
0  clang           0x00000000021fe4a5 llvm::sys::PrintStackTrace(_IO_FILE*) + 37
1  clang           0x00000000021fe8e3
2  libpthread.so.0 0x000000336520f710
3  libc.so.6       0x0000003364632925 gsignal + 53
4  libc.so.6       0x0000003364634105 abort + 373
5  libc.so.6       0x000000336462ba4e
6  libc.so.6       0x000000336462bb10 __assert_perror_fail + 0
7  clang           0x0000000001188626
8  clang           0x00000000011894eb clang::consumed::ConsumedStmtVisitor::VisitCXXMemberCallExpr(clang::CXXMemberCallExpr const*) + 27
9  clang           0x000000000118dc98 clang::consumed::ConsumedAnalyzer::run(clang::AnalysisDeclContext&) + 1160
10 clang           0x0000000000da60e6 clang::sema::AnalysisBasedWarnings::IssueWarnings(clang::sema::AnalysisBasedWarnings::Policy, clang::sema::FunctionScopeInfo*, clang::Decl const*, clang::BlockExpr const*) + 4518
11 clang           0x0000000000a4b4c3 clang::Sema::PopFunctionScopeInfo(clang::sema::AnalysisBasedWarnings::Policy const*, clang::Decl const*, clang::BlockExpr const*) + 99
12 clang           0x0000000000aefcb3 clang::Sema::ActOnFinishFunctionBody(clang::Decl*, clang::Stmt*, bool) + 3299
13 clang           0x0000000000a1fe4b clang::Parser::ParseFunctionStatementBody(clang::Decl*, clang::Parser::ParseScope&) + 283
14 clang           0x00000000009aea65 clang::Parser::ParseFunctionDefinition(clang::ParsingDeclarator&, clang::Parser::ParsedTemplateInfo const&, clang::Parser::LateParsedAttrList*) + 2053
15 clang           0x00000000009c035d clang::Parser::ParseDeclGroup(clang::ParsingDeclSpec&, unsigned int, bool, clang::SourceLocation*, clang::Parser::ForRangeInit*) + 1357
16 clang           0x00000000009ae0d2 clang::Parser::ParseDeclOrFunctionDefInternal(clang::Parser::ParsedAttributesWithRange&, clang::ParsingDeclSpec&, clang::AccessSpecifier) + 690
17 clang           0x00000000009adb13 clang::Parser::ParseDeclarationOrFunctionDefinition(clang::Parser::ParsedAttributesWithRange&, clang::ParsingDeclSpec*, clang::AccessSpecifier) + 403
18 clang           0x00000000009acd3d clang::Parser::ParseExternalDeclaration(clang::Parser::ParsedAttributesWithRange&, clang::ParsingDeclSpec*) + 2493
19 clang           0x00000000009ac2a3 clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&) + 483
20 clang           0x00000000009a8686 clang::ParseAST(clang::Sema&, bool, bool) + 454
21 clang           0x0000000000834d82 clang::CodeGenAction::ExecuteAction() + 514
22 clang           0x00000000006aa560 clang::FrontendAction::Execute() + 112
23 clang           0x000000000068789d clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) + 925
24 clang           0x000000000066ee40 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) + 2880
25 clang           0x0000000000666a4f cc1_main(char const**, char const**, char const*, void*) + 687
26 clang           0x000000000066d0a0 main + 9136
27 libc.so.6       0x000000336461ed1d __libc_start_main + 253
28 clang           0x00000000006666d9
Stack dump:
0.	Program arguments: /usr/local/bin/clang -cc1 -triple x86_64-unknown-linux-gnu -emit-obj -mrelax-all -disable-free -main-file-name move.cc -mrelocation-model static -mdisable-fp-elim -fmath-errno -masm-verbose -mconstructor-aliases -munwind-tables -target-cpu x86-64 -target-linker-version 2.20.51.0.2 -resource-dir /usr/local/bin/../lib/clang/3.5 -internal-isystem /usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../include/c++/4.4.7 -internal-isystem /usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../include/c++/4.4.7/x86_64-redhat-linux -internal-isystem /usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../include/c++/4.4.7/backward -internal-isystem /usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../include/x86_64-redhat-linux/c++/4.4.7 -internal-isystem /usr/local/include -internal-isystem /usr/local/bin/../lib/clang/3.5/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Weverything -fdeprecated-macro -fdebug-compilation-dir /tmp/move-test -ferror-limit 19 -fmessage-length 146 -mstackrealign -fobjc-runtime=gcc -fcxx-exceptions -fexceptions -fdiagnostics-show-option -fcolor-diagnostics -vectorize-slp -o /tmp/move-a63530.o -x c++ ./move.cc 
1.	<eof> parser at end of file
2.	./move.cc:7:1: parsing function body 'main'
clang: error: unable to execute command: Aborted (core dumped)
clang: error: clang frontend command failed due to signal (use -v to see invocation)
clang version 3.5 (trunk 197368)
Target: x86_64-unknown-linux-gnu
Thread model: posix
clang: note: diagnostic msg: PLEASE submit a bug report to http://llvm.org/bugs/ and include the crash backtrace, preprocessed source, and associated run script.
clang: note: diagnostic msg: 
********************

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

********************
Comment 1 Jesper Juhl 2013-12-16 04:09:16 PST
Created attachment 11738 [details]
preprocessed source for reproduce test case
Comment 2 Jesper Juhl 2013-12-16 04:09:52 PST
Created attachment 11739 [details]
run script for reproduce test case
Comment 3 jonathan.sauer 2013-12-16 05:16:00 PST
The warning that causes the crash is -Wconsumed, at least on r196769 (slightly older than Jesper's). Compiling with -Weverything -Wno-consumed makes the crash go away.
Comment 4 jonathan.sauer 2013-12-16 05:17:04 PST
See http://clang.llvm.org/docs/LanguageExtensions.html#consumed-annotation-checking for information about -Wconsumed.
Comment 5 rtrieu 2013-12-16 15:43:31 PST
Fixed in r197428.