public inbox for gdb-cvs@sourceware.org help / color / mirror / Atom feed
From: Enze Li <lienze@sourceware.org> To: gdb-cvs@sourceware.org Subject: [binutils-gdb] gdb: some int to bool conversion Date: Tue, 24 Jan 2023 03:20:14 +0000 (GMT) [thread overview] Message-ID: <20230124032014.C2D673858D33@sourceware.org> (raw) https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=59d49a8d83a289624a1dff4e8833f2b7c286d764 commit 59d49a8d83a289624a1dff4e8833f2b7c286d764 Author: Enze Li <enze.li@hotmail.com> Date: Sun Jan 22 13:38:41 2023 +0800 gdb: some int to bool conversion When building GDB with clang 16, I got this, CXX maint.o maint.c:1045:23: error: implicit truncation from 'int' to a one-bit wide bit-field changes value from 1 to -1 [-Werror,-Wsingle-bit-bitfield-constant-conversion] m_space_enabled = 1; ^ ~ maint.c:1057:22: error: implicit truncation from 'int' to a one-bit wide bit-field changes value from 1 to -1 [-Werror,-Wsingle-bit-bitfield-constant-conversion] m_time_enabled = 1; ^ ~ maint.c:1073:24: error: implicit truncation from 'int' to a one-bit wide bit-field changes value from 1 to -1 [-Werror,-Wsingle-bit-bitfield-constant-conversion] m_symtab_enabled = 1; ^ ~ 3 errors generated. Work around this by using bool bitfields instead. Tested by rebuilding on x86_64-linux with clang 16 and gcc 12. Approved-By: Tom Tromey <tom@tromey.com> Diff: --- gdb/maint.c | 12 ++++++------ gdb/maint.h | 6 +++--- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/gdb/maint.c b/gdb/maint.c index 1a226bf75e3..52f91a3246f 100644 --- a/gdb/maint.c +++ b/gdb/maint.c @@ -1042,11 +1042,11 @@ scoped_command_stats::scoped_command_stats (bool msg_type) #ifdef HAVE_USEFUL_SBRK char *lim = (char *) sbrk (0); m_start_space = lim - lim_at_start; - m_space_enabled = 1; + m_space_enabled = true; #endif } else - m_space_enabled = 0; + m_space_enabled = false; if (msg_type == 0 || per_command_time) { @@ -1054,13 +1054,13 @@ scoped_command_stats::scoped_command_stats (bool msg_type) m_start_cpu_time = run_time_clock::now (); m_start_wall_time = steady_clock::now (); - m_time_enabled = 1; + m_time_enabled = true; if (per_command_time) print_time (_("command started")); } else - m_time_enabled = 0; + m_time_enabled = false; if (msg_type == 0 || per_command_symtab) { @@ -1070,10 +1070,10 @@ scoped_command_stats::scoped_command_stats (bool msg_type) m_start_nr_symtabs = nr_symtabs; m_start_nr_compunit_symtabs = nr_compunit_symtabs; m_start_nr_blocks = nr_blocks; - m_symtab_enabled = 1; + m_symtab_enabled = true; } else - m_symtab_enabled = 0; + m_symtab_enabled = false; /* Initialize timer to keep track of how long we waited for the user. */ reset_prompt_for_continue_wait_time (); diff --git a/gdb/maint.h b/gdb/maint.h index 09a68c17bef..1741d132567 100644 --- a/gdb/maint.h +++ b/gdb/maint.h @@ -49,9 +49,9 @@ class scoped_command_stats /* Track whether the stat was enabled at the start of the command so that we can avoid printing anything if it gets turned on by the current command. */ - int m_time_enabled : 1; - int m_space_enabled : 1; - int m_symtab_enabled : 1; + bool m_time_enabled : 1; + bool m_space_enabled : 1; + bool m_symtab_enabled : 1; run_time_clock::time_point m_start_cpu_time; std::chrono::steady_clock::time_point m_start_wall_time; long m_start_space;
next reply other threads:[~2023-01-24 3:20 UTC|newest] Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top 2023-01-24 3:20 Enze Li [this message] -- strict thread matches above, loose matches on Subject: below -- 2021-05-07 16:01 Andrew Burgess
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=20230124032014.C2D673858D33@sourceware.org \ --to=lienze@sourceware.org \ --cc=gdb-cvs@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: linkBe 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; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).