Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions clang/lib/AST/ByteCode/Interp.h
Original file line number Diff line number Diff line change
Expand Up @@ -1788,6 +1788,8 @@ inline bool GetPtrBase(InterpState &S, CodePtr OpPC, uint32_t Off) {
return false;

if (!Ptr.isBlockPointer()) {
if (!Ptr.isIntegralPointer())
return false;
S.Stk.push<Pointer>(Ptr.asIntPointer().baseCast(S.getASTContext(), Off));
return true;
}
Expand All @@ -1809,6 +1811,8 @@ inline bool GetPtrBasePop(InterpState &S, CodePtr OpPC, uint32_t Off,
return false;

if (!Ptr.isBlockPointer()) {
if (!Ptr.isIntegralPointer())
return false;
S.Stk.push<Pointer>(Ptr.asIntPointer().baseCast(S.getASTContext(), Off));
return true;
}
Expand Down
14 changes: 13 additions & 1 deletion clang/test/AST/ByteCode/typeid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,12 @@ struct __type_info_implementations {
typedef __unique_impl __impl;
};

class type_info {
class __pointer_type_info {
public:
int __flags = 0;
};

class type_info : public __pointer_type_info {
protected:
typedef __type_info_implementations::__impl __impl;
__impl::__type_name_t __type_name;
Expand All @@ -40,3 +45,10 @@ constexpr bool test() {
return true;
}
static_assert(test());

int dontcrash() {
auto& pti = static_cast<const std::__pointer_type_info&>(
typeid(int)
);
return pti.__flags == 0 ? 1 : 0;
}