Skip to content

Commit 673ecd2

Browse files
ClaytonKnittelcopybara-github
authored andcommitted
Automated rollback of commit 94e62c6.
PiperOrigin-RevId: 821225222
1 parent f39612a commit 673ecd2

File tree

1 file changed

+3
-12
lines changed

1 file changed

+3
-12
lines changed

src/google/protobuf/repeated_field.h

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -110,24 +110,16 @@ struct RepeatedFieldBase {};
110110
template <size_t kMinSize>
111111
class HeapRep {
112112
public:
113-
explicit HeapRep(uint32_t capacity) : capacity_(capacity) {
114-
StaticallyVerifySize();
115-
}
113+
explicit HeapRep(uint32_t capacity) : capacity_(capacity) {}
116114
// Avoid 'implicitly deleted dtor' warnings on certain compilers.
117115
~HeapRep() = delete;
118116

119117
uint32_t capacity() const { return capacity_; }
120118

121-
const void* elements() const { return elements_; }
122-
void* elements() { return elements_; }
119+
const void* elements() const { return this + 1; }
120+
void* elements() { return this + 1; }
123121

124122
private:
125-
static constexpr void StaticallyVerifySize() {
126-
static_assert(sizeof(HeapRep) == offsetof(HeapRep, elements_),
127-
"`elements_` must be the last member of `HeapRep` and "
128-
"consume no space.");
129-
}
130-
131123
// Align to 8 as sanitizers are picky on the alignment of containers to start
132124
// at 8 byte offsets even when compiling for 32 bit platforms.
133125
union {
@@ -140,7 +132,6 @@ class HeapRep {
140132
// power-of-two sized allocations, which enables Arena optimizations.
141133
char padding_[kMinSize];
142134
};
143-
void* elements_[];
144135
};
145136
#else
146137
template <size_t kMinSize>

0 commit comments

Comments
 (0)