llvm / llvm-project

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.
http://llvm.org
Other
28.65k stars 11.84k forks source link

Anonymous struct as member in non POD class fails to compile under certain situations #11283

Closed llvmbot closed 13 years ago

llvmbot commented 13 years ago
Bugzilla Link 10911
Resolution WORKSFORME
Resolved on Sep 12, 2011 13:59
Version unspecified
OS MacOS X
Attachments Test code (and Xcode project)
Reporter LLVM Bugzilla Contributor
CC @DougGregor,@efriedma-quic,@tkremenek

Extended Description

Naming the struct resolves the issue, but there shouldn't be an issue with the anon struct.

Compiler output: 0 clang 0x00000001085bc212 _ZL15PrintStackTracePv + 34 1 clang 0x00000001085bc6e9 _ZL13SignalHandleri + 633 2 libsystem_c.dylib 0x00007fff8b694cfa _sigtramp + 26 3 libsystem_c.dylib 0x0000000008c19250 _sigtramp + 18446603338324133232 4 clang 0x0000000107a8db5a llvm::GetElementPtrInst::GetElementPtrInst<llvm::Value*>(llvm::Value, llvm::Value, llvm::Value, unsigned int, llvm::Twine const&, llvm::Instruction) + 202 5 clang 0x0000000107e6dad9 llvm::IRBuilder<false, llvm::ConstantFolder, llvm::IRBuilderDefaultInserter >::CreateConstInBoundsGEP2_32(llvm::Value, unsigned int, unsigned int, llvm::Twine const&) + 185 6 clang 0x0000000107a8d7bc clang::CodeGen::CodeGenFunction::EmitLValueForField(llvm::Value, clang::FieldDecl const, unsigned int) + 492 7 clang 0x0000000107ce3045 clang::CodeGen::CodeGenFunction::EmitLValueForFieldInitialization(llvm::Value, clang::FieldDecl const, unsigned int) + 85 8 clang 0x0000000107cde5fa clang::CodeGen::CodeGenFunction::EmitCtorPrologue(clang::CXXConstructorDecl const, clang::CXXCtorType, clang::CodeGen::FunctionArgList&) + 1322 9 clang 0x0000000107cddd14 clang::CodeGen::CodeGenFunction::EmitConstructorBody(clang::CodeGen::FunctionArgList&) + 340 10 clang 0x0000000107e5fe83 clang::CodeGen::CodeGenFunction::GenerateCode(clang::GlobalDecl, llvm::Function, clang::CodeGen::CGFunctionInfo const&) + 675 11 clang 0x0000000107cddb83 clang::CodeGen::CodeGenModule::EmitCXXConstructor(clang::CXXConstructorDecl const, clang::CXXCtorType) + 243 12 clang 0x0000000107e618ed clang::CodeGen::CodeGenModule::EmitGlobalDefinition(clang::GlobalDecl) + 285 13 clang 0x0000000107e6234d clang::CodeGen::CodeGenModule::EmitGlobal(clang::GlobalDecl) + 605 14 clang 0x00000001078490f7 clang::CodeGen::CodeGenModule::EmitTopLevelDecl(clang::Decl) + 311 15 clang 0x00000001078490bb clang::CodeGen::CodeGenModule::EmitTopLevelDecl(clang::Decl) + 251 16 clang 0x0000000107848f9f (anonymous namespace)::CodeGeneratorImpl::HandleTopLevelDecl(clang::DeclGroupRef) + 95 17 clang 0x0000000107848f11 clang::BackendConsumer::HandleTopLevelDecl(clang::DeclGroupRef) + 161 18 clang 0x000000010781cff2 clang::ParseAST(clang::Sema&, bool) + 290 19 clang 0x000000010781baaf clang::CodeGenAction::ExecuteAction() + 671 20 clang 0x000000010780789b clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) + 875 21 clang 0x0000000107805918 clang::ExecuteCompilerInvocation(clang::CompilerInstance) + 2696 22 clang 0x00000001077fa115 cc1_main(char const, char const, char const, void) + 5333 23 clang 0x00000001077dd27b main + 667 24 clang 0x00000001077dcfd4 start + 52 25 clang 0x0000000000000052 start + 18446744069288898738 Stack dump:

  1. Program arguments: /Developer/usr/bin/clang -cc1 -triple x86_64-apple-macosx10.7.0 -emit-obj -mrelax-all -disable-free -disable-llvm-verifier -main-file-name TestClass.cpp -pic-level 1 -mdisable-fp-elim -relaxed-aliasing -masm-verbose -munwind-tables -target-cpu core2 -target-linker-version 127 -g -coverage-file /Users/jweinberg/Library/Developer/Xcode/DerivedData/AnonUnion-dnprncphbwlxlphjiptrydjahpge/Build/Intermediates/AnonUnion.build/Debug/AnonUnion.build/Objects-normal/x86_64/TestClass.o -resource-dir /Developer/usr/bin/../lib/clang/3.0 -dependency-file /Users/jweinberg/Library/Developer/Xcode/DerivedData/AnonUnion-dnprncphbwlxlphjiptrydjahpge/Build/Intermediates/AnonUnion.build/Debug/AnonUnion.build/Objects-normal/x86_64/TestClass.d -MT dependencies -isysroot /Developer/SDKs/MacOSX10.7.sdk -iquote /Users/jweinberg/Library/Developer/Xcode/DerivedData/AnonUnion-dnprncphbwlxlphjiptrydjahpge/Build/Intermediates/AnonUnion.build/Debug/AnonUnion.build/AnonUnion-generated-files.hmap -iquote /Users/jweinberg/Library/Developer/Xcode/DerivedData/AnonUnion-dnprncphbwlxlphjiptrydjahpge/Build/Intermediates/AnonUnion.build/Debug/AnonUnion.build/AnonUnion-project-headers.hmap -D DEBUG=1 -I /Users/jweinberg/Library/Developer/Xcode/DerivedData/AnonUnion-dnprncphbwlxlphjiptrydjahpge/Build/Intermediates/AnonUnion.build/Debug/AnonUnion.build/AnonUnion-own-target-headers.hmap -I /Users/jweinberg/Library/Developer/Xcode/DerivedData/AnonUnion-dnprncphbwlxlphjiptrydjahpge/Build/Intermediates/AnonUnion.build/Debug/AnonUnion.build/AnonUnion-all-target-headers.hmap -I /Users/jweinberg/Library/Developer/Xcode/DerivedData/AnonUnion-dnprncphbwlxlphjiptrydjahpge/Build/Products/Debug/include -I /Users/jweinberg/Library/Developer/Xcode/DerivedData/AnonUnion-dnprncphbwlxlphjiptrydjahpge/Build/Intermediates/AnonUnion.build/Debug/AnonUnion.build/DerivedSources/x86_64 -I /Users/jweinberg/Library/Developer/Xcode/DerivedData/AnonUnion-dnprncphbwlxlphjiptrydjahpge/Build/Intermediates/AnonUnion.build/Debug/AnonUnion.build/DerivedSources -F/Users/jweinberg/Library/Developer/Xcode/DerivedData/AnonUnion-dnprncphbwlxlphjiptrydjahpge/Build/Products/Debug -O0 -Wno-trigraphs -Wmissing-prototypes -Wreturn-type -Wparentheses -Wswitch -Wno-unused-parameter -Wunused-variable -Wunused-value -Wshorten-64-to-32 -Wc++0x-extensions -Wno-sign-conversion -fdeprecated-macro -ferror-limit 19 -fmessage-length 0 -fvisibility-inlines-hidden -fdiagnostics-print-source-range-info -fdiagnostics-parseable-fixits -stack-protector 1 -fblocks -fcxx-exceptions -fexceptions -fpascal-strings -fdiagnostics-show-option -fdiagnostics-show-category id -o /Users/jweinberg/Library/Developer/Xcode/DerivedData/AnonUnion-dnprncphbwlxlphjiptrydjahpge/Build/Intermediates/AnonUnion.build/Debug/AnonUnion.build/Objects-normal/x86_64/TestClass.o -x c++ /Users/jweinberg/Development/AnonUnion/AnonUnion/TestClass.cpp
  2. parser at end of file
  3. /Users/jweinberg/Development/AnonUnion/AnonUnion/TestClass.cpp:13:11: LLVM IR generation of declaration 'Test'
  4. /Users/jweinberg/Development/AnonUnion/AnonUnion/TestClass.cpp:15:16: Generating code for declaration 'Test::TestClass::TestClass' clang: error: unable to execute command: Segmentation fault: 11 clang: error: clang frontend command failed due to signal 2 (use -v to see invocation)

Compiler version is Apple clang version 3.0 (tags/Apple/clang-211.9) (based on LLVM 3.0svn)

llvmbot commented 13 years ago

I'll go ahead and pull down a trunk build to test with.

efriedma-quic commented 13 years ago

This is working with trunk clang.

tkremenek commented 13 years ago

cloned to rdar://problem/10110345