Skip to content

Commit

Permalink
Put [[no_unique_address]] back on the Array's array storage
Browse files Browse the repository at this point in the history
MSVC has fixed the bug where [[msvc::no_unique_address]] on an array
would break its alignment. Previous MSVC versions can't even compile
Subspace so we don't need to worry about supporting them here.
  • Loading branch information
danakj committed Nov 25, 2023
1 parent 5f26f53 commit c59c89c
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 6 deletions.
5 changes: 2 additions & 3 deletions sus/collections/array.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,8 @@ namespace __private {

template <class T, size_t N>
struct Storage final {
sus_msvc_bug_10416202_else(
[[sus_no_unique_address]]) sus::iter::IterRefCounter iter_refs_;
T data_[N];
[[sus_no_unique_address]] sus::iter::IterRefCounter iter_refs_;
[[sus_no_unique_address]] T data_[N];
};

template <class T>
Expand Down
4 changes: 1 addition & 3 deletions sus/collections/invalidation_off_size_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,7 @@ using sus::Slice;

constexpr usize array_padding = 0u
// No support for no_unique_address in clang-cl.
sus_clang_bug_49358(+sizeof(i32))
// MSVC bug with no_unique_address and arrays, so not used here.
sus_clang_bug_49358_else(sus_msvc_bug_10416202(+sizeof(i32)));
sus_clang_bug_49358(+sizeof(i32));

static_assert(alignof(Array<i32, 5>) == alignof(i32));
static_assert(sizeof(Array<i32, 5>) == sizeof(i32) * 5 + array_padding);
Expand Down

0 comments on commit c59c89c

Please sign in to comment.