[llvm-bugs] [Bug 49534] New: A/F: Assertion `!IsUnion && "Unions cannot be dynamic classes."' failed.

via llvm-bugs llvm-bugs at lists.llvm.org
Thu Mar 11 01:41:18 PST 2021


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

            Bug ID: 49534
           Summary: A/F: Assertion `!IsUnion && "Unions cannot be dynamic
                    classes."' failed.
           Product: new-bugs
           Version: trunk
          Hardware: PC
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: new bugs
          Assignee: unassignedbugs at nondot.org
          Reporter: douglas_yung at playstation.sony.com
                CC: htmldeveloper at gmail.com, llvm-bugs at lists.llvm.org

We have a negative test case internally that started to hit an assertion
failure when compiled with clang. I bisected the issue to commit
7e5cea5b509f5535eab6d1ea9b90e033570758a6 after which the compiler emits an
assertion failure when trying to compile the code.

The code being compiled is the following:

/* repro2.cpp */
union {
  virtual int a( ;
    int b
/* end repro2.cpp */

Note that this is taken from a test that is not supposed to compile correctly.
The original test was expecting a diagnostic from the compiler to be emitted,
and I was able to reduce it to the above code fragment.

Compiling with a compiler built from the previous commit
85801b4c68ee4f1c7b9f2a33162d852b577fe536 yields the following output:

dyung at aldebaran:~/sandbox/7971$
~/src/upstream/85801b4c68ee4f1c7b9f2a33162d852b577fe536-linux/bin/clang -c
repro2.cpp
repro2.cpp:2:18: error: expected parameter declarator
  virtual int a( ;
                 ^
repro2.cpp:2:18: error: expected ')'
repro2.cpp:2:16: note: to match this '('
  virtual int a( ;
               ^
repro2.cpp:2:3: error: unions cannot have virtual functions
  virtual int a( ;
  ^
repro2.cpp:3:10: error: expected ';' at end of declaration list
    int b
         ^
         ;
repro2.cpp:3:10: error: expected '}'
repro2.cpp:1:7: note: to match this '{'
union {
      ^
repro2.cpp:3:10: error: expected ';' after union
    int b
         ^
         ;
repro2.cpp:1:1: error: anonymous unions at namespace or global scope must be
declared 'static'
union {
^
static 
repro2.cpp:2:15: error: functions cannot be declared in an anonymous union
  virtual int a( ;
              ^
8 errors generated.

If I compile the same code with a compiler built from
7e5cea5b509f5535eab6d1ea9b90e033570758a6, it emits the same output as above,
but additionally hits the following assertion failure:

clang:
/home/dyung/src/upstream/llvm_clean_git/clang/lib/AST/RecordLayoutBuilder.cpp:1069:
void {anonymous}::ItaniumRecordLayoutBuilder::LayoutNonVirtualBases(const
clang::CXXRecordDecl*): Assertion `!IsUnion && "Unions cannot be dynamic c
lasses."' failed.                                                               
PLEASE submit a bug report to https://bugs.llvm.org/ and include the crash
backtrace, preprocessed source, and associated run script.                      
Stack dump:                                                                     
0.      Program arguments:
/home/dyung/src/upstream//7e5cea5b509f5535eab6d1ea9b90e033570758a6-linux/bin/clang
-c repro2.cpp                                                                   
1.      <eof> parser at end of file                                             
 #0 0x0000563248537cf1 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int)
(/home/dyung/src/upstream//7e5cea5b509f5535eab6d1ea9b90e033570758a6-linux/bin/clang+0x3612cf1) 
 #1 0x00005632485359a4 llvm::sys::RunSignalHandlers()
(/home/dyung/src/upstream//7e5cea5b509f5535eab6d1ea9b90e033570758a6-linux/bin/clang+0x36109a4) 
 #2 0x0000563248535c41 llvm::sys::CleanupOnSignal(unsigned long)
(/home/dyung/src/upstream//7e5cea5b509f5535eab6d1ea9b90e033570758a6-linux/bin/clang+0x3610c41) 
 #3 0x000056324848fba8 CrashRecoverySignalHandler(int)
CrashRecoveryContext.cpp:0:0                                                    
 #4 0x00007f4b2fdd73c0 __restore_rt
(/lib/x86_64-linux-gnu/libpthread.so.0+0x153c0)                                 
 #5 0x00007f4b2f89318b raise
/build/glibc-eX1tMB/glibc-2.31/signal/../sysdeps/unix/sysv/linux/raise.c:51:1   
 #6 0x00007f4b2f872859 abort /build/glibc-eX1tMB/glibc-2.31/stdlib/abort.c:81:7 
 #7 0x00007f4b2f872729 get_sysdep_segment_value
/build/glibc-eX1tMB/glibc-2.31/intl/loadmsgcat.c:509:8                          
 #8 0x00007f4b2f872729 _nl_load_domain
/build/glibc-eX1tMB/glibc-2.31/intl/loadmsgcat.c:970:34                         
 #9 0x00007f4b2f883f36 (/lib/x86_64-linux-gnu/libc.so.6+0x36f36)                
#10 0x000056324b2f0e0c clang::ASTContext::getASTRecordLayout(clang::RecordDecl
const*) const
(/home/dyung/src/upstream//7e5cea5b509f5535eab6d1ea9b90e033570758a6-linux/bin/clang+0x63cbe0c)
                                                   #11 0x000056324af588ea
clang::ASTContext::getTypeInfoImpl(clang::Type const*) const
(/home/dyung/src/upstream//7e5cea5b509f5535eab6d1ea9b90e033570758a6-linux/bin/clang+0x60338ea)
#12 0x000056324af4cf0f clang::ASTContext::getTypeInfo(clang::Type const*) const
(/home/dyung/src/upstream//7e5cea5b509f5535eab6d1ea9b90e033570758a6-linux/bin/clang+0x6027f0f)
                                                                #13
0x000056324af57c86 clang::ASTContext::getTypeAlignInChars(clang::QualType)
const
(/home/dyung/src/upstream//7e5cea5b509f5535eab6d1ea9b90e033570758a6-linux/bin/clang+0x6032c86)
#14 0x000056324a4c27f4 clang::Sema::CheckArgAlignment(clang::SourceLocation,
clang::NamedDecl*, llvm::StringRef, clang::QualType, clang::QualType)
(/home/dyung/src/upstream//7e5cea5b509f5535eab6d1ea9b90e033570758a6-linux/bin/clang+0x559d7f4) 
#15 0x000056324a4f138c clang::Sema::CheckConstructorCall(clang::FunctionDecl*,
clang::QualType, llvm::ArrayRef<clang::Expr const*>, clang::FunctionProtoType
const*, clang::SourceLocation)
(/home/dyung/src/upstream//7e5cea5b509f5535eab6d1ea9b90e033570758a6-linux/bin/clang+0x55cc38c) 
#16 0x000056324a67142e
clang::Sema::CompleteConstructorCall(clang::CXXConstructorDecl*,
clang::QualType, llvm::MutableArrayRef<clang::Expr*>, clang::SourceLocation,
llvm::SmallVectorImpl<clang::Expr*>&, bool, bool)
(/home/dyung/src/upstream//7e5cea5b509f5535eab6d1ea9b90e033570758a6-linux/bin/clang+0x574c42e)
#17 0x000056324a920565 PerformConstructorInitialization(clang::Sema&,
clang::InitializedEntity const&, clang::InitializationKind const&,
llvm::MutableArrayRef<clang::Expr*>, clang::InitializationSequence::Step
const&, bool&, bool, bool, cl
ang::SourceLocation, clang::SourceLocation) SemaInit.cpp:0:0                   
                                                                               
                                                                              
#18 0x000056324a939cf4 clang::InitializationSequence::Perform(clang::Sema&,
clang::InitializedEntity const&, clang::InitializationKind const&,
llvm::MutableArrayRef<clang::Expr*>, clang::QualType*)
(/home/dyung/src/upstream//7e5cea5b509f55
35eab6d1ea9b90e033570758a6-linux/bin/clang+0x5a14cf4)                          
                                                                               
                                                                              
#19 0x000056324a5d1625 clang::Sema::ActOnUninitializedDecl(clang::Decl*)
(.part.0) SemaDecl.cpp:0:0
#20 0x000056324a5d2a3b clang::Sema::BuildAnonymousStructOrUnion(clang::Scope*,
clang::DeclSpec&, clang::AccessSpecifier, clang::RecordDecl*,
clang::PrintingPolicy const&)
(/home/dyung/src/upstream//7e5cea5b509f5535eab6d1ea9b90e033570758a6-
linux/bin/clang+0x56ada3b)                                                     
                                                                               
                                                                              
#21 0x000056324a5d3a81 clang::Sema::ParsedFreeStandingDeclSpec(clang::Scope*,
clang::AccessSpecifier, clang::DeclSpec&,
llvm::MutableArrayRef<clang::TemplateParameterList*>, bool,
clang::RecordDecl*&) (/home/dyung/src/upstream//7e5cea5b509
f5535eab6d1ea9b90e033570758a6-linux/bin/clang+0x56aea81)                        
#22 0x000056324a5d4547 clang::Sema::ParsedFreeStandingDeclSpec(clang::Scope*,
clang::AccessSpecifier, clang::DeclSpec&, clang::RecordDecl*&)
(/home/dyung/src/upstream//7e5cea5b509f5535eab6d1ea9b90e033570758a6-linux/bin/clang+0x56af547) 
#23 0x000056324a32b9dd
clang::Parser::ParseDeclOrFunctionDefInternal(clang::Parser::ParsedAttributesWithRange&,
clang::ParsingDeclSpec&, clang::AccessSpecifier)
(/home/dyung/src/upstream//7e5cea5b509f5535eab6d1ea9b90e033570758a6-linux/bin/
clang+0x54069dd)                                                                
#24 0x000056324a32c1e1
clang::Parser::ParseDeclarationOrFunctionDefinition(clang::Parser::ParsedAttributesWithRange&,
clang::ParsingDeclSpec*, clang::AccessSpecifier) (.part.0) Parser.cpp:0:0       
#25 0x000056324a3326d0
clang::Parser::ParseExternalDeclaration(clang::Parser::ParsedAttributesWithRange&,
clang::ParsingDeclSpec*)
(/home/dyung/src/upstream//7e5cea5b509f5535eab6d1ea9b90e033570758a6-linux/bin/clang+0x540d6d0) 
#26 0x000056324a333618
clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&, bool)
(/home/dyung/src/upstream//7e5cea5b509f5535eab6d1ea9b90e033570758a6-linux/bin/clang+0x540e618) 
#27 0x000056324a333a4a
clang::Parser::ParseFirstTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&)
(/home/dyung/src/upstream//7e5cea5b509f5535eab6d1ea9b90e033570758a6-linux/bin/clang+0x540ea4a) 
#28 0x000056324a3267aa clang::ParseAST(clang::Sema&, bool, bool)
(/home/dyung/src/upstream//7e5cea5b509f5535eab6d1ea9b90e033570758a6-linux/bin/clang+0x54017aa) 
#29 0x00005632495f9948 clang::CodeGenAction::ExecuteAction()
(/home/dyung/src/upstream//7e5cea5b509f5535eab6d1ea9b90e033570758a6-linux/bin/clang+0x46d4948) 
#30 0x0000563248ede9e9 clang::FrontendAction::Execute()
(/home/dyung/src/upstream//7e5cea5b509f5535eab6d1ea9b90e033570758a6-linux/bin/clang+0x3fb99e9)
#31 0x0000563248e744ee
clang::CompilerInstance::ExecuteAction(clang::FrontendAction&)
(/home/dyung/src/upstream//7e5cea5b509f5535eab6d1ea9b90e033570758a6-linux/bin/clang+0x3f4f4ee)
                                                          #32
0x0000563248fb6190 clang::ExecuteCompilerInvocation(clang::CompilerInstance*)
(/home/dyung/src/upstream//7e5cea5b509f5535eab6d1ea9b90e033570758a6-linux/bin/clang+0x4091190)
#33 0x0000563245f77dc6 cc1_main(llvm::ArrayRef<char const*>, char const*,
void*)
(/home/dyung/src/upstream//7e5cea5b509f5535eab6d1ea9b90e033570758a6-linux/bin/clang+0x1052dc6) 
#34 0x0000563245f74108 ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&)
driver.cpp:0:0                                                                  
#35 0x0000563248d11ba9 void llvm::function_ref<void
()>::callback_fn<clang::driver::CC1Command::Execute(llvm::ArrayRef<llvm::Optional<llvm::StringRef>
>, std::__cxx11::basic_string<char, std::char_traits<char>,
std::allocator<char> >*, boo
l*) const::'lambda'()>(long) Job.cpp:0:0                                       
                                                                               
                                                                              
#36 0x000056324848fd2c
llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>)
(/home/dyung/src/upstream//7e5cea5b509f5535eab6d1ea9b90e033570758a6-linux/bin/clang+0x356ad2c)
#37 0x0000563248d12527
clang::driver::CC1Command::Execute(llvm::ArrayRef<llvm::Optional<llvm::StringRef>
>, std::__cxx11::basic_string<char, std::char_traits<char>,
std::allocator<char> >*, bool*) const (.part.0) Job.cpp:0:0               #38
0x0000563248ce4c5b
clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&,
clang::driver::Command const*&) const
(/home/dyung/src/upstream//7e5cea5b509f5535eab6d1ea9b90e033570758a6-linux/bin/clang+0x3dbfc5b)
#39 0x0000563248ce5779
clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&,
llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*> >&) const
(/home/dyung/src/upstream//7e5cea5b509f5535eab6d1ea9b90e033570758a6
-linux/bin/clang+0x3dc0779)
#40 0x0000563248cf06c9
clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&,
llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*> >&)
(/home/dyung/src/upstream//7e5cea5b509f5535eab6d1ea9b90e033570758a6-linux
/bin/clang+0x3dcb6c9)                                                           
#41 0x0000563245ea5769 main
(/home/dyung/src/upstream//7e5cea5b509f5535eab6d1ea9b90e033570758a6-linux/bin/clang+0xf80769) 
#42 0x00007f4b2f8740b3 __libc_start_main
/build/glibc-eX1tMB/glibc-2.31/csu/../csu/libc-start.c:342:3                    
#43 0x0000563245f73c5e _start
(/home/dyung/src/upstream//7e5cea5b509f5535eab6d1ea9b90e033570758a6-linux/bin/clang+0x104ec5e) 
clang-13: error: clang frontend command failed with exit code 134 (use -v to
see invocation)                                                                 
clang version 13.0.0 (https://github.com/llvm/llvm-project.git
7e5cea5b509f5535eab6d1ea9b90e033570758a6)                                       
Target: x86_64-unknown-linux-gnu                                                
Thread model: posix                                                             
InstalledDir:
/home/dyung/src/upstream//7e5cea5b509f5535eab6d1ea9b90e033570758a6-linux/bin

-- 
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/20210311/f0dd41c5/attachment-0001.html>


More information about the llvm-bugs mailing list