[llvm-bugs] [Bug 46111] New: -ast-dump assert on GCC9.x std::string

via llvm-bugs llvm-bugs at lists.llvm.org
Wed May 27 17:59:18 PDT 2020


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

            Bug ID: 46111
           Summary: -ast-dump assert on GCC9.x std::string
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: C++17
          Assignee: unassignedclangbugs at nondot.org
          Reporter: erich.keane at intel.com
                CC: blitzrakete at gmail.com, erik.pilkington at gmail.com,
                    llvm-bugs at lists.llvm.org, richard-llvm at metafoo.co.uk

Minimized from a compilation of std::string in GCC9.x, it seems the deduction
guide ends up having an elaborated type specifier, but the assert claims
otherwise.    The following test is a massive creduced version of the test, so
the names are messed up.

First, the assert:

  | |-FunctionTemplateDecl 0x1196d290 <line:4:1, line:7:6> col:3 implicit
<deduction guide for d>
  | | |-TemplateTypeParmDecl 0x1193e8d8 <line:4:11> col:19 typename depth 0
index 0
  | | |-TemplateTypeParmDecl 0x1193e960 <col:21> col:29 typename depth 0 index
1
  | | |-TemplateTypeParmDecl 0x1193ea10 <col:31, col:40> col:40 referenced
typename depth 0 index 2 c
  | | `-CXXDeductionGuideDecl 0x1196d1e0 <line:7:3, col:6> col:3 implicit
<deduction guide for d> '
llvm-project/clang/lib/AST/NestedNameSpecifier.cpp:304: void
clang::NestedNameSpecifier::print(llvm::raw_ostream&, const
clang::PrintingPolicy&, bool) const: Assertion `!isa<ElaboratedType>(T) &&
"Elaborated type in nested-name-specifier"' failed.

Stack Trace:
Stack dump:
0.      Program arguments: ./bin/clang @crash.args
1.      <eof> parser at end of file
 #0 0x00000000049a607c llvm::sys::PrintStackTrace(llvm::raw_ostream&)
/iusers/ekeane1/workspaces/llvm-project/llvm/lib/Support/Unix/Signals.inc:564:22
 #1 0x00000000049a610f PrintStackTraceSignalHandler(void*)
/iusers/ekeane1/workspaces/llvm-project/llvm/lib/Support/Unix/Signals.inc:625:1
 #2 0x00000000049a419f llvm::sys::RunSignalHandlers()
/iusers/ekeane1/workspaces/llvm-project/llvm/lib/Support/Signals.cpp:68:20
 #3 0x00000000049a5abf SignalHandler(int)
/iusers/ekeane1/workspaces/llvm-project/llvm/lib/Support/Unix/Signals.inc:406:1
 #4 0x00007fc76a2755e0 __restore_rt (/lib64/libpthread.so.0+0xf5e0)
 #5 0x00007fc768dee1f7 raise (/lib64/libc.so.6+0x351f7)
 #6 0x00007fc768def8e8 abort (/lib64/libc.so.6+0x368e8)
 #7 0x00007fc768de7266 __assert_fail_base (/lib64/libc.so.6+0x2e266)
 #8 0x00007fc768de7312 (/lib64/libc.so.6+0x2e312)
 #9 0x000000000867e80e clang::NestedNameSpecifier::print(llvm::raw_ostream&,
clang::PrintingPolicy const&, bool) const (.localalias.0)
/iusers/ekeane1/workspaces/llvm-project/clang/lib/AST/NestedNameSpecifier.cpp:303:5
#10 0x0000000008772706 (anonymous
namespace)::TypePrinter::printDependentNameBefore(clang::DependentNameType
const*, llvm::raw_ostream&)
/iusers/ekeane1/workspaces/llvm-project/clang/lib/AST/TypePrinter.cpp:1437:37
#11 0x000000000876d41d (anonymous
namespace)::TypePrinter::printBefore(clang::Type const*, clang::Qualifiers,
llvm::raw_ostream&)
/iusers/ekeane1/workspaces/llvm-project/build/tools/clang/include/clang/AST/TypeNodes.inc:39:1
#12 0x000000000876cdbc (anonymous namespace)::TypePrinter::print(clang::Type
const*, clang::Qualifiers, llvm::raw_ostream&, llvm::StringRef)
/iusers/ekeane1/workspaces/llvm-project/clang/lib/AST/TypePrinter.cpp:186:9
#13 0x000000000876cd3c (anonymous
namespace)::TypePrinter::print(clang::QualType, llvm::raw_ostream&,
llvm::StringRef)
/iusers/ekeane1/workspaces/llvm-project/clang/lib/AST/TypePrinter.cpp:174:1
#14 0x00000000087702f6 (anonymous
namespace)::TypePrinter::printFunctionProtoAfter(clang::FunctionProtoType
const*, llvm::raw_ostream&)
/iusers/ekeane1/workspaces/llvm-project/clang/lib/AST/TypePrinter.cpp:827:5
#15 0x000000000876de31 (anonymous
namespace)::TypePrinter::printAfter(clang::Type const*, clang::Qualifiers,
llvm::raw_ostream&)
/iusers/ekeane1/workspaces/llvm-project/build/tools/clang/include/clang/AST/TypeNodes.inc:47:1
#16 0x000000000876cdea (anonymous namespace)::TypePrinter::print(clang::Type
const*, clang::Qualifiers, llvm::raw_ostream&, llvm::StringRef)
/iusers/ekeane1/workspaces/llvm-project/clang/lib/AST/TypePrinter.cpp:183:70
#17 0x0000000008774326 clang::QualType::getAsStringInternal(clang::Type const*,
clang::Qualifiers, std::__cxx11::basic_string<char, std::char_traits<char>,
std::allocator<char> >&, clang::PrintingPolicy const&)
/iusers/ekeane1/workspaces/llvm-project/clang/lib/AST/TypePrinter.cpp:1990:43
#18 0x00000000087740f6 clang::QualType::getAsString[abi:cxx11](clang::Type
const*, clang::Qualifiers, clang::PrintingPolicy const&)
/iusers/ekeane1/workspaces/llvm-project/clang/lib/AST/TypePrinter.cpp:1960:10
#19 0x0000000008658e40
clang::QualType::getAsString[abi:cxx11](clang::SplitQualType,
clang::PrintingPolicy const&)
/iusers/ekeane1/workspaces/llvm-project/clang/include/clang/AST/Type.h:994:3
#20 0x000000000871ab09 clang::TextNodeDumper::dumpBareType(clang::QualType,
bool)
/iusers/ekeane1/workspaces/llvm-project/clang/lib/AST/TextNodeDumper.cpp:394:58
#21 0x000000000871ac60 clang::TextNodeDumper::dumpType(clang::QualType)
/iusers/ekeane1/workspaces/llvm-project/clang/lib/AST/TextNodeDumper.cpp:407:1
#22 0x000000000871f10d
clang::TextNodeDumper::VisitFunctionDecl(clang::FunctionDecl const*)
/iusers/ekeane1/workspaces/llvm-project/clang/lib/AST/TextNodeDumper.cpp:1320:39
#23 0x000000000873bae9 clang::declvisitor::Base<llvm::make_const_ptr,
clang::TextNodeDumper,
void>::VisitCXXDeductionGuideDecl(clang::CXXDeductionGuideDecl const*)
/iusers/ekeane1/workspaces/llvm-project/build/tools/clang/include/clang/AST/DeclNodes.inc:405:1
#24 0x0000000008736338 clang::declvisitor::Base<llvm::make_const_ptr,
clang::TextNodeDumper, void>::Visit(clang::Decl const*)
/iusers/ekeane1/workspaces/llvm-project/build/tools/clang/include/clang/AST/DeclNodes.inc:405:1
#25 0x000000000871a1b8 clang::TextNodeDumper::Visit(clang::Decl const*)
/iusers/ekeane1/workspaces/llvm-project/clang/lib/AST/TextNodeDumper.cpp:281:1
#26 0x00000000082a370b clang::ASTNodeTraverser<clang::ASTDumper,
clang::TextNodeDumper>::Visit(clang::Decl const*)::'lambda'()::operator()()
const
/iusers/ekeane1/workspaces/llvm-project/clang/include/clang/AST/ASTNodeTraverser.h:83:5
#27 0x00000000082acbab void
clang::TextTreeStructure::AddChild<clang::ASTNodeTraverser<clang::ASTDumper,
clang::TextNodeDumper>::Visit(clang::Decl const*)::'lambda'()>(llvm::StringRef,
clang::ASTDumper)::'lambda'(bool)::operator()(bool) const
/iusers/ekeane1/workspaces/llvm-project/clang/include/clang/AST/TextNodeDumper.h:103:20
#28 0x00000000082c783e std::_Function_handler<void (bool), void
clang::TextTreeStructure::AddChild<clang::ASTNodeTraverser<clang::ASTDumper,
clang::TextNodeDumper>::Visit(clang::Decl const*)::'lambda'()>(llvm::StringRef,
clang::ASTDumper)::'lambda'(bool)>::_M_invoke(std::_Any_data const&, bool&&)
/nfs/pdx/proj/icl/rdrive/ref/gcc/8.3.0/rhel70/efi2/include/c++/8.3.0/bits/std_function.h:299:7
#29 0x00000000082acfba std::function<void (bool)>::operator()(bool) const
/nfs/pdx/proj/icl/rdrive/ref/gcc/8.3.0/rhel70/efi2/include/c++/8.3.0/bits/std_function.h:687:71
#30 0x00000000082acbeb void
clang::TextTreeStructure::AddChild<clang::ASTNodeTraverser<clang::ASTDumper,
clang::TextNodeDumper>::Visit(clang::Decl const*)::'lambda'()>(llvm::StringRef,
clang::ASTDumper)::'lambda'(bool)::operator()(bool) const
/iusers/ekeane1/workspaces/llvm-project/clang/include/clang/AST/TextNodeDumper.h:72:10
#31 0x00000000082c783e std::_Function_handler<void (bool), void
clang::TextTreeStructure::AddChild<clang::ASTNodeTraverser<clang::ASTDumper,
clang::TextNodeDumper>::Visit(clang::Decl const*)::'lambda'()>(llvm::StringRef,
clang::ASTDumper)::'lambda'(bool)>::_M_invoke(std::_Any_data const&, bool&&)
/nfs/pdx/proj/icl/rdrive/ref/gcc/8.3.0/rhel70/efi2/include/c++/8.3.0/bits/std_function.h:299:7
#32 0x00000000082acfba std::function<void (bool)>::operator()(bool) const
/nfs/pdx/proj/icl/rdrive/ref/gcc/8.3.0/rhel70/efi2/include/c++/8.3.0/bits/std_function.h:687:71
#33 0x00000000082aceba void
clang::TextTreeStructure::AddChild<clang::ASTNodeTraverser<clang::ASTDumper,
clang::TextNodeDumper>::Visit(clang::Decl const*)::'lambda'()>(llvm::StringRef,
clang::ASTDumper)
/iusers/ekeane1/workspaces/llvm-project/clang/include/clang/AST/TextNodeDumper.h:116:33
#34 0x00000000082a587f void
clang::TextTreeStructure::AddChild<clang::ASTNodeTraverser<clang::ASTDumper,
clang::TextNodeDumper>::Visit(clang::Decl
const*)::'lambda'()>(clang::ASTDumper)
/iusers/ekeane1/workspaces/llvm-project/clang/include/clang/AST/TextNodeDumper.h:49:3
#35 0x00000000082a38ae clang::ASTNodeTraverser<clang::ASTDumper,
clang::TextNodeDumper>::Visit(clang::Decl const*)
/iusers/ekeane1/workspaces/llvm-project/clang/include/clang/AST/ASTNodeTraverser.h:103:3
#36 0x00000000082a581f clang::ASTNodeTraverser<clang::ASTDumper,
clang::TextNodeDumper>::dumpDeclContext(clang::DeclContext const*)
/iusers/ekeane1/workspaces/llvm-project/clang/include/clang/AST/ASTNodeTraverser.h:252:5
#37 0x00000000082a3862 clang::ASTNodeTraverser<clang::ASTDumper,
clang::TextNodeDumper>::Visit(clang::Decl const*)::'lambda'()::operator()()
const
/iusers/ekeane1/workspaces/llvm-project/clang/include/clang/AST/ASTNodeTraverser.h:100:11
#38 0x00000000082acbab void
clang::TextTreeStructure::AddChild<clang::ASTNodeTraverser<clang::ASTDumper,
clang::TextNodeDumper>::Visit(clang::Decl const*)::'lambda'()>(llvm::StringRef,
clang::ASTDumper)::'lambda'(bool)::operator()(bool) const
/iusers/ekeane1/workspaces/llvm-project/clang/include/clang/AST/TextNodeDumper.h:103:20
#39 0x00000000082c783e std::_Function_handler<void (bool), void
clang::TextTreeStructure::AddChild<clang::ASTNodeTraverser<clang::ASTDumper,
clang::TextNodeDumper>::Visit(clang::Decl const*)::'lambda'()>(llvm::StringRef,
clang::ASTDumper)::'lambda'(bool)>::_M_invoke(std::_Any_data const&, bool&&)
/nfs/pdx/proj/icl/rdrive/ref/gcc/8.3.0/rhel70/efi2/include/c++/8.3.0/bits/std_function.h:299:7
#40 0x00000000082acfba std::function<void (bool)>::operator()(bool) const
/nfs/pdx/proj/icl/rdrive/ref/gcc/8.3.0/rhel70/efi2/include/c++/8.3.0/bits/std_function.h:687:71
#41 0x00000000082aceba void
clang::TextTreeStructure::AddChild<clang::ASTNodeTraverser<clang::ASTDumper,
clang::TextNodeDumper>::Visit(clang::Decl const*)::'lambda'()>(llvm::StringRef,
clang::ASTDumper)
/iusers/ekeane1/workspaces/llvm-project/clang/include/clang/AST/TextNodeDumper.h:116:33
#42 0x00000000082a587f void
clang::TextTreeStructure::AddChild<clang::ASTNodeTraverser<clang::ASTDumper,
clang::TextNodeDumper>::Visit(clang::Decl
const*)::'lambda'()>(clang::ASTDumper)
/iusers/ekeane1/workspaces/llvm-project/clang/include/clang/AST/TextNodeDumper.h:49:3
#43 0x00000000082a38ae clang::ASTNodeTraverser<clang::ASTDumper,
clang::TextNodeDumper>::Visit(clang::Decl const*)
/iusers/ekeane1/workspaces/llvm-project/clang/include/clang/AST/ASTNodeTraverser.h:103:3
#44 0x00000000082a581f clang::ASTNodeTraverser<clang::ASTDumper,
clang::TextNodeDumper>::dumpDeclContext(clang::DeclContext const*)
/iusers/ekeane1/workspaces/llvm-project/clang/include/clang/AST/ASTNodeTraverser.h:252:5
#45 0x00000000082a3862 clang::ASTNodeTraverser<clang::ASTDumper,
clang::TextNodeDumper>::Visit(clang::Decl const*)::'lambda'()::operator()()
const
/iusers/ekeane1/workspaces/llvm-project/clang/include/clang/AST/ASTNodeTraverser.h:100:11
#46 0x00000000082acbab void
clang::TextTreeStructure::AddChild<clang::ASTNodeTraverser<clang::ASTDumper,
clang::TextNodeDumper>::Visit(clang::Decl const*)::'lambda'()>(llvm::StringRef,
clang::ASTDumper)::'lambda'(bool)::operator()(bool) const
/iusers/ekeane1/workspaces/llvm-project/clang/include/clang/AST/TextNodeDumper.h:103:20
#47 0x00000000082c783e std::_Function_handler<void (bool), void
clang::TextTreeStructure::AddChild<clang::ASTNodeTraverser<clang::ASTDumper,
clang::TextNodeDumper>::Visit(clang::Decl const*)::'lambda'()>(llvm::StringRef,
clang::ASTDumper)::'lambda'(bool)>::_M_invoke(std::_Any_data const&, bool&&)
/nfs/pdx/proj/icl/rdrive/ref/gcc/8.3.0/rhel70/efi2/include/c++/8.3.0/bits/std_function.h:299:7
#48 0x00000000082acfba std::function<void (bool)>::operator()(bool) const
/nfs/pdx/proj/icl/rdrive/ref/gcc/8.3.0/rhel70/efi2/include/c++/8.3.0/bits/std_function.h:687:71
#49 0x00000000082acd6a void
clang::TextTreeStructure::AddChild<clang::ASTNodeTraverser<clang::ASTDumper,
clang::TextNodeDumper>::Visit(clang::Decl const*)::'lambda'()>(llvm::StringRef,
clang::ASTDumper)
/iusers/ekeane1/workspaces/llvm-project/clang/include/clang/AST/TextNodeDumper.h:61:25
#50 0x00000000082a587f void
clang::TextTreeStructure::AddChild<clang::ASTNodeTraverser<clang::ASTDumper,
clang::TextNodeDumper>::Visit(clang::Decl
const*)::'lambda'()>(clang::ASTDumper)
/iusers/ekeane1/workspaces/llvm-project/clang/include/clang/AST/TextNodeDumper.h:49:3
#51 0x00000000082a38ae clang::ASTNodeTraverser<clang::ASTDumper,
clang::TextNodeDumper>::Visit(clang::Decl const*)
/iusers/ekeane1/workspaces/llvm-project/clang/include/clang/AST/ASTNodeTraverser.h:103:3
#52 0x000000000829fa3d clang::Decl::dump(llvm::raw_ostream&, bool,
clang::ASTDumpOutputFormat) const
/iusers/ekeane1/workspaces/llvm-project/clang/lib/AST/ASTDumper.cpp:193:77
#53 0x000000000551a14d (anonymous namespace)::ASTPrinter::print(clang::Decl*)
/iusers/ekeane1/workspaces/llvm-project/clang/lib/Frontend/ASTConsumers.cpp:96:5
#54 0x0000000005519d59 (anonymous
namespace)::ASTPrinter::HandleTranslationUnit(clang::ASTContext&)
/iusers/ekeane1/workspaces/llvm-project/clang/lib/Frontend/ASTConsumers.cpp:48:23
#55 0x0000000007210892 clang::ParseAST(clang::Sema&, bool, bool)
/iusers/ekeane1/workspaces/llvm-project/clang/lib/Parse/ParseAST.cpp:178:14
#56 0x00000000054ad9f5 clang::ASTFrontendAction::ExecuteAction()
/iusers/ekeane1/workspaces/llvm-project/clang/lib/Frontend/FrontendAction.cpp:1060:11
#57 0x00000000054ad35d clang::FrontendAction::Execute()
/iusers/ekeane1/workspaces/llvm-project/clang/lib/Frontend/FrontendAction.cpp:957:38
#58 0x0000000005448ac7
clang::CompilerInstance::ExecuteAction(clang::FrontendAction&)
/iusers/ekeane1/workspaces/llvm-project/clang/lib/Frontend/CompilerInstance.cpp:973:42
#59 0x000000000560e530
clang::ExecuteCompilerInvocation(clang::CompilerInstance*)
/iusers/ekeane1/workspaces/llvm-project/clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp:282:38
#60 0x000000000208e24c cc1_main(llvm::ArrayRef<char const*>, char const*,
void*)
/iusers/ekeane1/workspaces/llvm-project/clang/tools/driver/cc1_main.cpp:240:40
#61 0x0000000002084257 ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&)
/iusers/ekeane1/workspaces/llvm-project/clang/tools/driver/driver.cpp:330:20
#62 0x0000000002084958 main
/iusers/ekeane1/workspaces/llvm-project/clang/tools/driver/driver.cpp:407:26
#63 0x00007fc768ddac05 __libc_start_main (/lib64/libc.so.6+0x21c05)
#64 0x0000000002082af9 _start (./bin/clang+0x2082af9)



My response file (AKA, command line args):
"-cc1"
-std=c++17"
"-ast-dump"
"-x"
"c++"
"preproc.pp"




The source:

   namespace a {
   template <typename> struct b;
   namespace {
   template <typename, typename, typename c> struct d {
     typedef a::b<c> e;
     typedef typename e::f f;
     d(f);
   };
   template <typename g, typename h = g, typename i> d(g, i)->d<h, h, i>;
   } // namespace
  } // namespace a


The value of 'T' when it crashes is:

ElaboratedType 0x10361cb0 'a::b<c>' sugar dependent                             
`-TemplateSpecializationType 0x10361c60 'b<c>' dependent b                      
  `-TemplateArgument type 'c' 


Anyone have an idea on where to start? Should we be de-sugaring in this case to
handle the elaborated type cases?  Should we not be creating the deduction
guides with the elaborated type in the first place?  Or should the assert
simply be removed?

-- 
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/20200528/dd8625da/attachment-0001.html>


More information about the llvm-bugs mailing list