[LLVMbugs] [Bug 8760] New: cannot codegen constructor initializer of pointer to templated type in a union

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Wed Dec 8 16:00:31 PST 2010


http://llvm.org/bugs/show_bug.cgi?id=8760

           Summary: cannot codegen constructor initializer of pointer to
                    templated type in a union
           Product: clang
           Version: trunk
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: LLVM Codegen
        AssignedTo: unassignedclangbugs at nondot.org
        ReportedBy: nlewycky at google.com
                CC: llvmbugs at cs.uiuc.edu


Testcase:

  template <typename T>
  struct Foo {
    Foo() : ptr(__nullptr) {}
    union {
      T *ptr;
   };
  };
  Foo<int> f;

this fails with:


nlewycky at ducttape:~$ llvm/Debug+Asserts/bin/clang++ -c union-init.cc
0  clang           0x0000000002252b21
1  clang           0x0000000002252914
2  libpthread.so.0 0x00007f9b549708f0
3  clang           0x0000000000f15afa
llvm::PointerIntPair<llvm::PointerUnion<clang::Type const*, clang::ExtQuals
const*>, 2u, unsigned int,
llvm::PointerLikeTypeTraits<llvm::PointerUnion<clang::Type const*,
clang::ExtQuals const*> > >::getPointer() const + 16
4  clang           0x0000000000f107ea
clang::QualType::hasLocalNonFastQualifiers() const + 24
5  clang           0x0000000000f106e0 clang::QualType::getTypePtr() const + 24
6  clang           0x0000000000f108b8 llvm::simplify_type<clang::QualType
const>::getSimplifiedValue(clang::QualType const&) + 24
7  clang           0x0000000000fa0323 llvm::isa_impl_wrap<clang::RecordType,
clang::QualType const, clang::Type*>::doit(clang::QualType const&) + 24
8  clang           0x0000000000fa0103 bool
llvm::isa_impl_cl<clang::QualType>::isa<clang::RecordType>(clang::QualType
const&) + 24

9  clang           0x0000000000f9f94f bool llvm::isa<clang::RecordType,
clang::QualType>(clang::QualType const&) + 24
10 clang           0x000000000111cd12 clang::Type::isRecordType() const + 24
11 clang           0x00000000011e2c3a
clang::CodeGen::CodeGenFunction::hasAggregateLLVMType(clang::QualType) + 32
12 clang           0x00000000011683aa
clang::CodeGen::CodeGenFunction::EmitScalarExpr(clang::Expr const*, bool) + 48
13 clang           0x00000000010fc66f
14 clang           0x00000000010fd091
clang::CodeGen::CodeGenFunction::EmitCtorPrologue(clang::CXXConstructorDecl
const*, clang::CXXCtorType, llvm::SmallVector<std::pair<clang::VarDecl const*,
clang::QualType>, 16u>&) + 327
15 clang           0x00000000010fcebd
clang::CodeGen::CodeGenFunction::EmitConstructorBody(llvm::SmallVector<std::pair<clang::VarDecl
const*, clang::QualType>, 16u>&) + 355
16 clang           0x00000000011e40a3
clang::CodeGen::CodeGenFunction::GenerateCode(clang::CodeGen::GlobalDecl,
llvm::Function*) + 835
17 clang           0x00000000010edc47
clang::CodeGen::CodeGenModule::EmitCXXConstructor(clang::CXXConstructorDecl
const*, clang::CXXCtorType) + 333
18 clang           0x00000000010a63f9
clang::CodeGen::CodeGenModule::EmitGlobalDefinition(clang::CodeGen::GlobalDecl)
+ 389

19 clang           0x00000000010a57e3
clang::CodeGen::CodeGenModule::EmitDeferred() + 355
20 clang           0x00000000010a3c32 clang::CodeGen::CodeGenModule::Release()
+ 24
21 clang           0x00000000010a0879
22 clang           0x000000000109e5ac
23 clang           0x00000000012069ff clang::ParseAST(clang::Sema&, bool) + 639
24 clang           0x0000000000f6cf45 clang::ASTFrontendAction::ExecuteAction()
+ 263
25 clang           0x000000000109f579 clang::CodeGenAction::ExecuteAction() +
951
26 clang           0x0000000000f6cb96 clang::FrontendAction::Execute() + 320
27 clang           0x0000000000f55a0d
clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) + 751
28 clang           0x0000000000f05819
clang::ExecuteCompilerInvocation(clang::CompilerInstance*) + 854
29 clang           0x0000000000ef8969 cc1_main(char const**, char const**, char
const*, void*) + 1032
30 clang           0x0000000000f01919 main + 499
31 libc.so.6       0x00007f9b53c4ac4d __libc_start_main + 253
32 clang           0x0000000000ef7fd9

Stack dump:
0.      Program arguments:
/usr/local/google/home/nlewycky/llvm/Debug+Asserts/bin/clang -cc1 -triple
x86_64-unknown-linux-gnu -emit-obj -mrelax-all -disable-free -main-file-name
union-init.cc -mrelocation-model static -mdisable-fp-elim -masm-verbose
-mconstructor-aliases -munwind-tables -target-cpu x86-64 -target-linker-version
2.20.1 -resource-dir
/usr/local/google/home/nlewycky/llvm/Debug+Asserts/bin/../lib/clang/2.9
-ferror-limit 19 -fmessage-length 80 -fexceptions -fgnu-runtime
-fdiagnostics-show-option -fcolor-diagnostics -o union-init.o -x c++
union-init.cc 
1.      <eof> parser at end of file
2.      Per-file LLVM IR generation
3.      union-init.cc:3:3: Generating code for declaration 'Foo<int>::Foo'
clang: error: unable to execute command: Segmentation fault
clang: error: clang frontend command failed due to signal 1 (use -v to see
invocation)

-- 
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.



More information about the llvm-bugs mailing list