This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Default initialize enum flags to 0


... so that we don't need to do it manually, and potentially forget.
For example, this allows to do:

  my_flags flags;

  ...

  flags |= some_flag;

gdb/ChangeLog:

	* common/enum-flags.h (enum_flags::enum_flags): Initialize
	m_enum_value to 0 in default constructor.
---
 gdb/common/enum-flags.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/gdb/common/enum-flags.h b/gdb/common/enum-flags.h
index 5b8c3ebc32..b1cf9a4644 100644
--- a/gdb/common/enum-flags.h
+++ b/gdb/common/enum-flags.h
@@ -117,6 +117,7 @@ private:
 public:
   /* Allow default construction, just like raw enums.  */
   enum_flags ()
+    : m_enum_value ((enum_type) 0)
   {}
 
   enum_flags (const enum_flags &other)
-- 
2.11.0


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]