Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [PATCH] Default initialize enum flags to 0
@ 2017-02-20 21:46 Simon Marchi
  2017-02-20 23:18 ` Pedro Alves
  0 siblings, 1 reply; 5+ messages in thread
From: Simon Marchi @ 2017-02-20 21:46 UTC (permalink / raw)
  To: gdb-patches; +Cc: Simon Marchi

... 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


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2017-02-21 16:51 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-02-20 21:46 [PATCH] Default initialize enum flags to 0 Simon Marchi
2017-02-20 23:18 ` Pedro Alves
2017-02-21  3:01   ` Simon Marchi
2017-02-21 11:16     ` Pedro Alves
2017-02-21 16:51       ` Simon Marchi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox