Skip to content

stdlib: remove some static assertions which may not hold #21606

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 28, 2019
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
7 changes: 0 additions & 7 deletions stdlib/public/SwiftShims/GlobalObjects.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,13 +102,6 @@ static_assert(
4 * sizeof(__swift_intptr_t) + sizeof(__swift_int64_t),
"_SwiftSetBodyStorage has unexpected size");

static_assert(std::is_pod<_SwiftEmptyArrayStorage>::value,
"empty array type should be POD");
static_assert(std::is_pod<_SwiftEmptyDictionarySingleton>::value,
"empty dictionary type should be POD");
static_assert(std::is_pod<_SwiftEmptySetSingleton>::value,
"empty set type should be POD");

}} // extern "C", namespace swift
#endif

Expand Down
2 changes: 0 additions & 2 deletions stdlib/public/SwiftShims/HeapObject.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,6 @@ __swift_size_t swift_weakRetainCount(HeapObject *obj);
#endif

#ifdef __cplusplus
static_assert(swift::IsTriviallyConstructible<HeapObject>::value,
"HeapObject must be trivially initializable");
static_assert(std::is_trivially_destructible<HeapObject>::value,
"HeapObject must be trivially destructible");

Expand Down
2 changes: 0 additions & 2 deletions stdlib/public/SwiftShims/RefCount.h
Original file line number Diff line number Diff line change
Expand Up @@ -1188,8 +1188,6 @@ class RefCounts {
typedef RefCounts<InlineRefCountBits> InlineRefCounts;
typedef RefCounts<SideTableRefCountBits> SideTableRefCounts;

static_assert(swift::IsTriviallyConstructible<InlineRefCounts>::value,
"InlineRefCounts must be trivially initializable");
static_assert(std::is_trivially_destructible<InlineRefCounts>::value,
"InlineRefCounts must be trivially destructible");

Expand Down
8 changes: 5 additions & 3 deletions stdlib/public/runtime/HeapObject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,11 @@ static HeapObject *_swift_allocObject_(HeapMetadata const *metadata,
assert(isAlignmentMask(requiredAlignmentMask));
auto object = reinterpret_cast<HeapObject *>(
swift_slowAlloc(requiredSize, requiredAlignmentMask));
// FIXME: this should be a placement new but that adds a null check
object->metadata = metadata;
object->refCounts.init();

// NOTE: this relies on the C++17 guaranteed semantics of no null-pointer
// check on the placement new allocator which we have observed on Windows,
// Linux, and macOS.
new (object) HeapObject(metadata);

// If leak tracking is enabled, start tracking this object.
SWIFT_LEAKS_START_TRACKING_OBJECT(object);
Expand Down