Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Simon Marchi <simon.marchi@ericsson.com>
To: <gdb-patches@sourceware.org>
Cc: Simon Marchi <simon.marchi@ericsson.com>
Subject: [PATCH] Default initialize enum flags to 0
Date: Mon, 20 Feb 2017 21:46:00 -0000	[thread overview]
Message-ID: <20170220214548.18024-1-simon.marchi@ericsson.com> (raw)

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


             reply	other threads:[~2017-02-20 21:46 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-02-20 21:46 Simon Marchi [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170220214548.18024-1-simon.marchi@ericsson.com \
    --to=simon.marchi@ericsson.com \
    --cc=gdb-patches@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox