GNU Binutils with patches for OS216
Revision | 23bcc18f470ee4364bd362a8b78c6c1415a9dadb (tree) |
---|---|
Time | 2017-04-25 09:42:03 |
Author | Pedro Alves <palves@redh...> |
Commiter | Pedro Alves |
Don't memcpy non-trivially-copyable types: Make enum_flags triv. copyable
The delete-memcpy-with-non-trivial-types patch exposed many instances
of this problem:
[...]
sizeof (T) * vec2_->num); \
So, VECs (given it's C roots) rely on memcpy/memcpy of VEC elements to
be well defined, in order to grow/reallocate its internal elements
array. This means that we can only put trivially copyable types in
VECs. E.g., if a type requires using a custom copy/move ctor to
relocate, then we can't put it in a VEC (so we use std::vector
instead). But, as shown above, we're violating that requirement.
btrace_insn is currently not trivially copyable, because it contains
an enum_flags field, and that is itself not trivially copyable. This
patch corrects that, by simply removing the user-provided copy
constructor and assignment operator. The compiler-generated versions
work just fine.
Note that std::vector relies on std::is_trivially_copyable too to know
whether it can reallocate its elements with memcpy/memmove instead of
having to call copy/move ctors and dtors, so if we have types in
std::vectors that weren't trivially copyable because of enum_flags,
this will make such vectors more efficient.
gdb/ChangeLog:
2017-04-25 Pedro Alves <palves@redhat.com>
* common/enum-flags.h (enum_flags): Don't implement copy ctor and
assignment operator.
@@ -1,3 +1,8 @@ | ||
1 | +2017-04-25 Pedro Alves <palves@redhat.com> | |
2 | + | |
3 | + * common/enum-flags.h (enum_flags): Don't implement copy ctor and | |
4 | + assignment operator. | |
5 | + | |
1 | 6 | 2017-04-24 Yao Qi <yao.qi@linaro.org> |
2 | 7 | |
3 | 8 | * doublest.c (convert_doublest_to_floatformat): Call |
@@ -120,16 +120,6 @@ public: | ||
120 | 120 | : m_enum_value ((enum_type) 0) |
121 | 121 | {} |
122 | 122 | |
123 | - enum_flags (const enum_flags &other) | |
124 | - : m_enum_value (other.m_enum_value) | |
125 | - {} | |
126 | - | |
127 | - enum_flags &operator= (const enum_flags &other) | |
128 | - { | |
129 | - m_enum_value = other.m_enum_value; | |
130 | - return *this; | |
131 | - } | |
132 | - | |
133 | 123 | /* If you get an error saying these two overloads are ambiguous, |
134 | 124 | then you tried to mix values of different enum types. */ |
135 | 125 | enum_flags (enum_type e) |