[llvm-bugs] [Bug 41082] New: Assertion `!R.empty() && (*R.begin())->isCXXClassMember()' failed on invalid C++ code

via llvm-bugs llvm-bugs at lists.llvm.org
Fri Mar 15 05:00:07 PDT 2019


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

            Bug ID: 41082
           Summary: Assertion `!R.empty() &&
                    (*R.begin())->isCXXClassMember()' failed on invalid
                    C++ code
           Product: clang
           Version: trunk
          Hardware: PC
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: C++
          Assignee: unassignedclangbugs at nondot.org
          Reporter: martin at martin.st
                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

If trying to compile the following snippet of broken C++ code, clang triggers a
failed assert:

$ cat clang-sema-assert.cpp 
struct A {
  memmove;
  namespace using ::memmove;
    a ( memmove
$ clang++ -c clang-sema-assert.cpp 
clang-sema-assert.cpp:2:3: error: C++ requires a type specifier for all
      declarations
  memmove;
  ^
clang-sema-assert.cpp:1:8: error: missing '}' at end of definition of 'A'
struct A {
       ^
clang-sema-assert.cpp:3:3: note: still within definition of 'A' here
  namespace using ::memmove;
  ^
clang-sema-assert.cpp:3:13: error: expected identifier or '{'
  namespace using ::memmove;
            ^
clang-sema-assert.cpp:3:19: error: no member named 'memmove' in the global
      namespace; did you mean 'A::memmove'?
  namespace using ::memmove;
                  ^~~~~~~~~
                  A::memmove
clang-sema-assert.cpp:2:3: note: 'A::memmove' declared here
  memmove;
  ^
clang-9: ../tools/clang/lib/Sema/SemaExprMember.cpp:90: IMAKind
ClassifyImplicitMemberAccess(clang::Sema&, const clang::LookupResult&):
Assertion `!R.empty() && (*R.begin())->isCXXClassMember()' failed.
Stack dump:
0.      Program arguments: /home/martin/code/llvm/build/bin/clang-9 -cc1
-triple x86_64-unknown-linux-gnu -emit-obj -mrelax-all -disable-free
-main-file-name clang-sema-assert.cpp -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 -coverage-notes-file
/home/martin/code/llvm/build/clang-sema-assert.gcno -resource-dir
/home/martin/code/llvm/build/lib/clang/9.0.0 -internal-isystem
/usr/lib/gcc/x86_64-linux-gnu/5.4.0/../../../../include/c++/5.4.0
-internal-isystem
/usr/lib/gcc/x86_64-linux-gnu/5.4.0/../../../../include/x86_64-linux-gnu/c++/5.4.0
-internal-isystem
/usr/lib/gcc/x86_64-linux-gnu/5.4.0/../../../../include/x86_64-linux-gnu/c++/5.4.0
-internal-isystem
/usr/lib/gcc/x86_64-linux-gnu/5.4.0/../../../../include/c++/5.4.0/backward
-internal-isystem /usr/local/include -internal-isystem
/home/martin/code/llvm/build/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/martin/code/llvm/build -ferror-limit 19
-fmessage-length 80 -fobjc-runtime=gcc -fcxx-exceptions -fexceptions
-fdiagnostics-show-option -fcolor-diagnostics -o clang-sema-assert.o -x c++
clang-sema-assert.cpp -faddrsig 
1.      clang-sema-assert.cpp:4:9: current parser token 'memmove'
 #0 0x0000000001ae5a2a llvm::sys::PrintStackTrace(llvm::raw_ostream&)
(/home/martin/code/llvm/build/bin/clang-9+0x1ae5a2a)
 #1 0x0000000001ae37cc llvm::sys::RunSignalHandlers()
(/home/martin/code/llvm/build/bin/clang-9+0x1ae37cc)
 #2 0x0000000001ae3937 SignalHandler(int)
(/home/martin/code/llvm/build/bin/clang-9+0x1ae3937)
 #3 0x00007f689e927390 __restore_rt
(/lib/x86_64-linux-gnu/libpthread.so.0+0x11390)
 #4 0x00007f689d699428 gsignal
/build/glibc-LK5gWL/glibc-2.23/signal/../sysdeps/unix/sysv/linux/raise.c:54:0
 #5 0x00007f689d69b02a abort /build/glibc-LK5gWL/glibc-2.23/stdlib/abort.c:91:0
 #6 0x00007f689d691bd7 __assert_fail_base
/build/glibc-LK5gWL/glibc-2.23/assert/assert.c:92:0
 #7 0x00007f689d691c82 (/lib/x86_64-linux-gnu/libc.so.6+0x2dc82)
 #8 0x0000000002d4c3ea
clang::Sema::BuildPossibleImplicitMemberExpr(clang::CXXScopeSpec const&,
clang::SourceLocation, clang::LookupResult&, clang::TemplateArgumentListInfo
const*, clang::Scope const*)
(/home/martin/code/llvm/build/bin/clang-9+0x2d4c3ea)
 #9 0x0000000002bb2320 clang::Sema::ClassifyName(clang::Scope*,
clang::CXXScopeSpec&, clang::IdentifierInfo*&, clang::SourceLocation,
clang::Token const&, bool, std::unique_ptr<clang::CorrectionCandidateCallback,
std::default_delete<clang::CorrectionCandidateCallback> >)
(/home/martin/code/llvm/build/bin/clang-9+0x2bb2320)
#10 0x0000000002999fd6 clang::Parser::TryAnnotateName(bool,
std::unique_ptr<clang::CorrectionCandidateCallback,
std::default_delete<clang::CorrectionCandidateCallback> >)
(/home/martin/code/llvm/build/bin/clang-9+0x2999fd6)
#11 0x0000000002a2fa7d
clang::Parser::isCXXDeclarationSpecifier(clang::Parser::TPResult, bool*)
(/home/martin/code/llvm/build/bin/clang-9+0x2a2fa7d)
#12 0x0000000002a33228 clang::Parser::TryParseParameterDeclarationClause(bool*,
bool) (/home/martin/code/llvm/build/bin/clang-9+0x2a33228)
#13 0x0000000002a336bd clang::Parser::isCXXFunctionDeclarator(bool*)
(/home/martin/code/llvm/build/bin/clang-9+0x2a336bd)
#14 0x00000000029bd13d clang::Parser::ParseDirectDeclarator(clang::Declarator&)
(/home/martin/code/llvm/build/bin/clang-9+0x29bd13d)
#15 0x00000000029ad967
clang::Parser::ParseDeclaratorInternal(clang::Declarator&, void
(clang::Parser::*)(clang::Declarator&))
(/home/martin/code/llvm/build/bin/clang-9+0x29ad967)
#16 0x00000000029ade12 clang::Parser::ParseDeclarator(clang::Declarator&)
(/home/martin/code/llvm/build/bin/clang-9+0x29ade12)
#17 0x00000000029b7672 clang::Parser::ParseDeclGroup(clang::ParsingDeclSpec&,
clang::DeclaratorContext, clang::SourceLocation*, clang::Parser::ForRangeInit*)
(/home/martin/code/llvm/build/bin/clang-9+0x29b7672)
#18 0x000000000299349c
clang::Parser::ParseDeclOrFunctionDefInternal(clang::Parser::ParsedAttributesWithRange&,
clang::ParsingDeclSpec&, clang::AccessSpecifier)
(/home/martin/code/llvm/build/bin/clang-9+0x299349c)
#19 0x0000000002993cb1
clang::Parser::ParseDeclarationOrFunctionDefinition(clang::Parser::ParsedAttributesWithRange&,
clang::ParsingDeclSpec*, clang::AccessSpecifier) (.part.220.constprop.223)
(/home/martin/code/llvm/build/bin/clang-9+0x2993cb1)
#20 0x0000000002993d0f
clang::Parser::ParseDeclarationOrFunctionDefinition(clang::Parser::ParsedAttributesWithRange&,
clang::ParsingDeclSpec*, clang::AccessSpecifier)
(/home/martin/code/llvm/build/bin/clang-9+0x2993d0f)
#21 0x0000000002998620
clang::Parser::ParseExternalDeclaration(clang::Parser::ParsedAttributesWithRange&,
clang::ParsingDeclSpec*) (/home/martin/code/llvm/build/bin/clang-9+0x2998620)
#22 0x0000000002998f1f
clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&)
(/home/martin/code/llvm/build/bin/clang-9+0x2998f1f)
#23 0x000000000298f6b3 clang::ParseAST(clang::Sema&, bool, bool)
(/home/martin/code/llvm/build/bin/clang-9+0x298f6b3)
#24 0x0000000002620faf clang::CodeGenAction::ExecuteAction()
(/home/martin/code/llvm/build/bin/clang-9+0x2620faf)
#25 0x000000000214cb3e clang::FrontendAction::Execute()
(/home/martin/code/llvm/build/bin/clang-9+0x214cb3e)
#26 0x0000000002114c06
clang::CompilerInstance::ExecuteAction(clang::FrontendAction&)
(/home/martin/code/llvm/build/bin/clang-9+0x2114c06)
#27 0x00000000021eb03c
clang::ExecuteCompilerInvocation(clang::CompilerInstance*)
(/home/martin/code/llvm/build/bin/clang-9+0x21eb03c)
#28 0x0000000000940c88 cc1_main(llvm::ArrayRef<char const*>, char const*,
void*) (/home/martin/code/llvm/build/bin/clang-9+0x940c88)
#29 0x00000000008d1219 main (/home/martin/code/llvm/build/bin/clang-9+0x8d1219)
#30 0x00007f689d684830 __libc_start_main
/build/glibc-LK5gWL/glibc-2.23/csu/../csu/libc-start.c:325:0
#31 0x000000000093cb59 _start
(/home/martin/code/llvm/build/bin/clang-9+0x93cb59)

-- 
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/20190315/17125a75/attachment-0001.html>


More information about the llvm-bugs mailing list