Skip to content

[PCH,Variadics] Create corrupted PCH if it includes libc++ <memory> file #9445

@llvmbot

Description

@llvmbot
Bugzilla Link 9073
Resolution FIXED
Resolved on Feb 01, 2011 09:39
Version trunk
OS MacOS X
Attachments Test files, Simple header
Reporter LLVM Bugzilla Contributor
CC @DougGregor

Extended Description

Precompiling a header that includes from libc++ in c++0x mode generate a 'corrupted' file.

When trying to use the generated file, clang assert with the following error:

fatal error: malformed or corrupted PCH file: 'incorrect encoding of pack expansion type'

The crash append when serializing this variadic template:

------------------------------- memory:3105
template
template<class ..._Args>
shared_ptr<_Tp>
shared_ptr<_Tp>::make_shared(_Args&& ...__args)
{
typedef __shared_ptr_emplace<_Tp, allocator<_Tp> > _CntrlBlk;
typedef allocator<_CntrlBlk> _A2;
typedef __allocator_destructor<_A2> _D2;
_A2 __a2;
unique_ptr<_CntrlBlk, _D2> __hold2(__a2.allocate(1), _D2(__a2, 1));
::new(__hold2.get()) _CntrlBlk(__a2, std::__1::forward<_Args>(__args)...);
shared_ptr<_Tp> __r;
__r._ptr = __hold2.get()->get();
__r._cntrl = __hold2.release();
__r.__enable_weak_this(__r._ptr);
return __r;
}
-------------------------------- memory:3121

To reproduce this issue, you can use the attached file:

clang version 2.9 (trunk 124376)

$ clang -x objective-c++-header -std=c++0x -stdlib=libc++ -c SharedPrefix.h -o SharedPrefix.h.pth
$ clang -x objective-c++ -std=c++0x -stdlib=libc++ -include SharedPrefix.h -c src.mm -o src.o
fatal error: malformed or corrupted PCH file: 'incorrect encoding of pack expansion type'
Assertion failed: (!isNull() && "Cannot retrieve a NULL type pointer"), function getCommonPtr, file /Volumes/MacPro/Projects/OpenSource/llvm/tools/clang/lib/AST/../../include/clang/AST/Type.h, line 388.

I also attach SharedPrefix.ii, the preprocessed version of SharedPrefix.h

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugzillaIssues migrated from bugzillac++11

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions