[llvm-bugs] [Bug 27312] New: clang crashes on valid C++ code: Assertion `!Friend->isDependentContext() && "can't handle friends with dependent contexts here"' failed

via llvm-bugs llvm-bugs at lists.llvm.org
Sun Apr 10 13:20:55 PDT 2016


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

            Bug ID: 27312
           Summary: clang crashes on valid C++ code: Assertion
                    `!Friend->isDependentContext() && "can't handle
                    friends with dependent contexts here"' failed
           Product: clang
           Version: trunk
          Hardware: PC
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: -New Bugs
          Assignee: unassignedclangbugs at nondot.org
          Reporter: su at cs.ucdavis.edu
                CC: llvm-bugs at lists.llvm.org
    Classification: Unclassified

The current clang trunk crashes when compiling the following test case on
x86_64-linux-gnu in both 32-bit and 64-bit modes. 

This is a regression from 3.8.x.


$ clang++ -v
clang version 3.9.0 (trunk 265893)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /usr/local/clang-trunk/bin
Found candidate GCC installation: /usr/lib/gcc/i686-linux-gnu/4.9
Found candidate GCC installation: /usr/lib/gcc/i686-linux-gnu/4.9.3
Found candidate GCC installation: /usr/lib/gcc/i686-linux-gnu/5.3.0
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.4
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.4.7
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.6
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.6.4
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.7
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.7.3
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.8
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.8.5
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.9
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.9.3
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/5.3.0
Selected GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.9
Candidate multilib: .;@m64
Candidate multilib: 32;@m32
Candidate multilib: x32;@mx32
Selected multilib: .;@m64
$
$ clang++-3.8 -c -w small.cpp
$
$ clang++-trunk -c -w small.cpp
clang-3.9:
/tmp/llvm-builder/llvm-source-trunk/tools/clang/lib/Sema/SemaAccess.cpp:336:
bool MightInstantiateTo(clang::Sema&, clang::DeclContext*,
clang::DeclContext*): Assertion `!Friend->isDependentContext() && "can't handle
friends with dependent contexts here"' failed.
#0 0x0000000001d73125 llvm::sys::PrintStackTrace(llvm::raw_ostream&)
(/usr/local/clang-trunk/bin/clang-3.9+0x1d73125)
#1 0x0000000001d710b6 llvm::sys::RunSignalHandlers()
(/usr/local/clang-trunk/bin/clang-3.9+0x1d710b6)
#2 0x0000000001d712d4 SignalHandler(int)
(/usr/local/clang-trunk/bin/clang-3.9+0x1d712d4)
#3 0x00007f13ebe9b340 __restore_rt
(/lib/x86_64-linux-gnu/libpthread.so.0+0x10340)
#4 0x00007f13eb0b9cc9 gsignal
/build/eglibc-3GlaMS/eglibc-2.19/signal/../nptl/sysdeps/unix/sysv/linux/raise.c:56:0
#5 0x00007f13eb0bd0d8 abort
/build/eglibc-3GlaMS/eglibc-2.19/stdlib/abort.c:91:0
#6 0x00007f13eb0b2b86 __assert_fail_base
/build/eglibc-3GlaMS/eglibc-2.19/assert/assert.c:92:0
#7 0x00007f13eb0b2c32 (/lib/x86_64-linux-gnu/libc.so.6+0x2fc32)
#8 0x000000000097c1b8 clang::FunctionProtoType::getParamType(unsigned int)
const [clone .part.32] (/usr/local/clang-trunk/bin/clang-3.9+0x97c1b8)
#9 0x0000000002a1f452 GetFriendKind(clang::Sema&, (anonymous
namespace)::EffectiveContext const&, clang::CXXRecordDecl const*) [clone
.isra.405] (/usr/local/clang-trunk/bin/clang-3.9+0x2a1f452)
#10 0x0000000002a20124 HasAccess(clang::Sema&, (anonymous
namespace)::EffectiveContext const&, clang::CXXRecordDecl const*,
clang::AccessSpecifier, (anonymous namespace)::AccessTarget const&)
(/usr/local/clang-trunk/bin/clang-3.9+0x2a20124)
#11 0x0000000002a209e5 IsAccessible(clang::Sema&, (anonymous
namespace)::EffectiveContext const&, (anonymous namespace)::AccessTarget&)
(/usr/local/clang-trunk/bin/clang-3.9+0x2a209e5)
#12 0x0000000002a2205b CheckEffectiveAccess(clang::Sema&, (anonymous
namespace)::EffectiveContext const&, clang::SourceLocation, (anonymous
namespace)::AccessTarget&) (/usr/local/clang-trunk/bin/clang-3.9+0x2a2205b)
#13 0x0000000002a22b9d CheckAccess(clang::Sema&, clang::SourceLocation,
(anonymous namespace)::AccessTarget&)
(/usr/local/clang-trunk/bin/clang-3.9+0x2a22b9d)
#14 0x0000000002a23a72 clang::Sema::CheckLookupAccess(clang::LookupResult
const&) (/usr/local/clang-trunk/bin/clang-3.9+0x2a23a72)
#15 0x0000000002c4d568 clang::Sema::BuildMemberReferenceExpr(clang::Expr*,
clang::QualType, clang::SourceLocation, bool, clang::CXXScopeSpec&,
clang::SourceLocation, clang::NamedDecl*, clang::DeclarationNameInfo const&,
clang::TemplateArgumentListInfo const*, clang::Scope const*,
clang::Sema::ActOnMemberAccessExtraArgs*)
(/usr/local/clang-trunk/bin/clang-3.9+0x2c4d568)
#16 0x0000000002c4d8cd clang::Sema::ActOnMemberAccessExpr(clang::Scope*,
clang::Expr*, clang::SourceLocation, clang::tok::TokenKind,
clang::CXXScopeSpec&, clang::SourceLocation, clang::UnqualifiedId&,
clang::Decl*) (/usr/local/clang-trunk/bin/clang-3.9+0x2c4d8cd)
#17 0x000000000285caee
clang::Parser::ParsePostfixExpressionSuffix(clang::ActionResult<clang::Expr*,
true>) (/usr/local/clang-trunk/bin/clang-3.9+0x285caee)
#18 0x0000000002857538 clang::Parser::ParseCastExpression(bool, bool, bool&,
clang::Parser::TypeCastState) (/usr/local/clang-trunk/bin/clang-3.9+0x2857538)
#19 0x000000000285a05d clang::Parser::ParseCastExpression(bool, bool,
clang::Parser::TypeCastState) (/usr/local/clang-trunk/bin/clang-3.9+0x285a05d)
#20 0x000000000285a0e9
clang::Parser::ParseAssignmentExpression(clang::Parser::TypeCastState)
(/usr/local/clang-trunk/bin/clang-3.9+0x285a0e9)
#21 0x000000000285a169
clang::Parser::ParseExpression(clang::Parser::TypeCastState)
(/usr/local/clang-trunk/bin/clang-3.9+0x285a169)
#22 0x00000000028979d6 clang::Parser::ParseExprStatement()
(/usr/local/clang-trunk/bin/clang-3.9+0x28979d6)
#23 0x00000000028965bf
clang::Parser::ParseStatementOrDeclarationAfterAttributes(llvm::SmallVector<clang::Stmt*,
32u>&, clang::Parser::AllowedContsructsKind, clang::SourceLocation*,
clang::Parser::ParsedAttributesWithRange&)
(/usr/local/clang-trunk/bin/clang-3.9+0x28965bf)
#24 0x00000000028969de
clang::Parser::ParseStatementOrDeclaration(llvm::SmallVector<clang::Stmt*,
32u>&, clang::Parser::AllowedContsructsKind, clang::SourceLocation*)
(/usr/local/clang-trunk/bin/clang-3.9+0x28969de)
#25 0x000000000289af59 clang::Parser::ParseCompoundStatementBody(bool)
(/usr/local/clang-trunk/bin/clang-3.9+0x289af59)
#26 0x000000000289e205 clang::Parser::ParseFunctionStatementBody(clang::Decl*,
clang::Parser::ParseScope&) (/usr/local/clang-trunk/bin/clang-3.9+0x289e205)
#27 0x0000000002821d11
clang::Parser::ParseLexedMethodDef(clang::Parser::LexedMethod&)
(/usr/local/clang-trunk/bin/clang-3.9+0x2821d11)
#28 0x0000000002821a8e
clang::Parser::ParseLexedMethodDefs(clang::Parser::ParsingClass&)
(/usr/local/clang-trunk/bin/clang-3.9+0x2821a8e)
#29 0x0000000002821a8e
clang::Parser::ParseLexedMethodDefs(clang::Parser::ParsingClass&)
(/usr/local/clang-trunk/bin/clang-3.9+0x2821a8e)
#30 0x0000000002852709
clang::Parser::ParseCXXMemberSpecification(clang::SourceLocation,
clang::SourceLocation, clang::Parser::ParsedAttributesWithRange&, unsigned int,
clang::Decl*) (/usr/local/clang-trunk/bin/clang-3.9+0x2852709)
#31 0x000000000285342f
clang::Parser::ParseClassSpecifier(clang::tok::TokenKind,
clang::SourceLocation, clang::DeclSpec&, clang::Parser::ParsedTemplateInfo
const&, clang::AccessSpecifier, bool, clang::Parser::DeclSpecContext,
clang::Parser::ParsedAttributesWithRange&)
(/usr/local/clang-trunk/bin/clang-3.9+0x285342f)
#32 0x00000000028358e7
clang::Parser::ParseDeclarationSpecifiers(clang::DeclSpec&,
clang::Parser::ParsedTemplateInfo const&, clang::AccessSpecifier,
clang::Parser::DeclSpecContext, clang::Parser::LateParsedAttrList*)
(/usr/local/clang-trunk/bin/clang-3.9+0x28358e7)
#33 0x00000000028aa503
clang::Parser::ParseSingleDeclarationAfterTemplate(unsigned int,
clang::Parser::ParsedTemplateInfo const&, clang::ParsingDeclRAIIObject&,
clang::SourceLocation&, clang::AccessSpecifier, clang::AttributeList*)
(/usr/local/clang-trunk/bin/clang-3.9+0x28aa503)
#34 0x00000000028abeae
clang::Parser::ParseTemplateDeclarationOrSpecialization(unsigned int,
clang::SourceLocation&, clang::AccessSpecifier, clang::AttributeList*)
(/usr/local/clang-trunk/bin/clang-3.9+0x28abeae)
#35 0x00000000028ac1ea
clang::Parser::ParseDeclarationStartingWithTemplate(unsigned int,
clang::SourceLocation&, clang::AccessSpecifier, clang::AttributeList*)
(/usr/local/clang-trunk/bin/clang-3.9+0x28ac1ea)
#36 0x0000000002840124 clang::Parser::ParseDeclaration(unsigned int,
clang::SourceLocation&, clang::Parser::ParsedAttributesWithRange&)
(/usr/local/clang-trunk/bin/clang-3.9+0x2840124)
#37 0x000000000281f402
clang::Parser::ParseExternalDeclaration(clang::Parser::ParsedAttributesWithRange&,
clang::ParsingDeclSpec*) (/usr/local/clang-trunk/bin/clang-3.9+0x281f402)
#38 0x000000000281fbb0
clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&)
(/usr/local/clang-trunk/bin/clang-3.9+0x281fbb0)
#39 0x000000000281726b clang::ParseAST(clang::Sema&, bool, bool)
(/usr/local/clang-trunk/bin/clang-3.9+0x281726b)
#40 0x00000000024d78be clang::CodeGenAction::ExecuteAction()
(/usr/local/clang-trunk/bin/clang-3.9+0x24d78be)
#41 0x00000000021bdfae clang::FrontendAction::Execute()
(/usr/local/clang-trunk/bin/clang-3.9+0x21bdfae)
#42 0x0000000002196766
clang::CompilerInstance::ExecuteAction(clang::FrontendAction&)
(/usr/local/clang-trunk/bin/clang-3.9+0x2196766)
#43 0x00000000022484b2
clang::ExecuteCompilerInvocation(clang::CompilerInstance*)
(/usr/local/clang-trunk/bin/clang-3.9+0x22484b2)
#44 0x0000000000ac1808 cc1_main(llvm::ArrayRef<char const*>, char const*,
void*) (/usr/local/clang-trunk/bin/clang-3.9+0xac1808)
#45 0x0000000000a7d31d main (/usr/local/clang-trunk/bin/clang-3.9+0xa7d31d)
#46 0x00007f13eb0a4ec5 __libc_start_main
/build/eglibc-3GlaMS/eglibc-2.19/csu/libc-start.c:321:0
#47 0x0000000000abd854 _start (/usr/local/clang-trunk/bin/clang-3.9+0xabd854)
Stack dump:
0.      Program arguments: /usr/local/clang-trunk/bin/clang-3.9 -cc1 -triple
x86_64-unknown-linux-gnu -emit-obj -mrelax-all -disable-free -main-file-name
small.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-file /data2/small.cpp -resource-dir
/usr/local/clang-trunk/bin/../lib/clang/3.9.0 -internal-isystem
/usr/lib/gcc/x86_64-linux-gnu/4.9/../../../../include/c++/4.9 -internal-isystem
/usr/lib/gcc/x86_64-linux-gnu/4.9/../../../../include/x86_64-linux-gnu/c++/4.9
-internal-isystem
/usr/lib/gcc/x86_64-linux-gnu/4.9/../../../../include/x86_64-linux-gnu/c++/4.9
-internal-isystem
/usr/lib/gcc/x86_64-linux-gnu/4.9/../../../../include/c++/4.9/backward
-internal-isystem /usr/local/include -internal-isystem
/usr/local/clang-trunk/bin/../lib/clang/3.9.0/include -internal-externc-isystem
/usr/include/x86_64-linux-gnu -internal-externc-isystem /include
-internal-externc-isystem /usr/include -w -fdeprecated-macro
-fdebug-compilation-dir /data2 -ferror-limit 19 -fmessage-length 159
-fobjc-runtime=gcc -fcxx-exceptions -fexceptions -fdiagnostics-show-option
-fcolor-diagnostics -o small.o -x c++ small.cpp
1.      small.cpp:28:10: current parser token ';'
2.      small.cpp:20:1: parsing struct/union/class body 'A'
3.      small.cpp:26:5: parsing function body 'f'
4.      small.cpp:26:5: in compound statement ('{}')
clang-3.9: error: unable to execute command: Aborted (core dumped)
clang-3.9: error: clang frontend command failed due to signal (use -v to see
invocation)
clang version 3.9.0 (trunk 265893)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /usr/local/tools/bin
clang-3.9: 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-3.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-3.9: note: diagnostic msg: /tmp/small-43a48f.cpp
clang-3.9: note: diagnostic msg: /tmp/small-43a48f.sh
clang-3.9: note: diagnostic msg:

********************
$


-----------------------------------


template < class T >
struct A
{ 
  template < T >
  struct B
  { 
    void f ();
  };
};

class C
{ 
  int i;
  template < class T >
  template < T >
  friend struct A < T >::B;
};

template < class T >
struct A < T * >
{ 
  template < T * >
  struct B
  { 
    void f ()
    { 
      C c;
      c.i;
    };
  };
};

-- 
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/20160410/8cc12dbf/attachment.html>


More information about the llvm-bugs mailing list