Skip to content

Commit 59d49a8

Browse files
committed
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 <[email protected]>
1 parent 7ebf464 commit 59d49a8

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

gdb/maint.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1042,25 +1042,25 @@ scoped_command_stats::scoped_command_stats (bool msg_type)
10421042
#ifdef HAVE_USEFUL_SBRK
10431043
char *lim = (char *) sbrk (0);
10441044
m_start_space = lim - lim_at_start;
1045-
m_space_enabled = 1;
1045+
m_space_enabled = true;
10461046
#endif
10471047
}
10481048
else
1049-
m_space_enabled = 0;
1049+
m_space_enabled = false;
10501050

10511051
if (msg_type == 0 || per_command_time)
10521052
{
10531053
using namespace std::chrono;
10541054

10551055
m_start_cpu_time = run_time_clock::now ();
10561056
m_start_wall_time = steady_clock::now ();
1057-
m_time_enabled = 1;
1057+
m_time_enabled = true;
10581058

10591059
if (per_command_time)
10601060
print_time (_("command started"));
10611061
}
10621062
else
1063-
m_time_enabled = 0;
1063+
m_time_enabled = false;
10641064

10651065
if (msg_type == 0 || per_command_symtab)
10661066
{
@@ -1070,10 +1070,10 @@ scoped_command_stats::scoped_command_stats (bool msg_type)
10701070
m_start_nr_symtabs = nr_symtabs;
10711071
m_start_nr_compunit_symtabs = nr_compunit_symtabs;
10721072
m_start_nr_blocks = nr_blocks;
1073-
m_symtab_enabled = 1;
1073+
m_symtab_enabled = true;
10741074
}
10751075
else
1076-
m_symtab_enabled = 0;
1076+
m_symtab_enabled = false;
10771077

10781078
/* Initialize timer to keep track of how long we waited for the user. */
10791079
reset_prompt_for_continue_wait_time ();

gdb/maint.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,9 @@ class scoped_command_stats
4949
/* Track whether the stat was enabled at the start of the command
5050
so that we can avoid printing anything if it gets turned on by
5151
the current command. */
52-
int m_time_enabled : 1;
53-
int m_space_enabled : 1;
54-
int m_symtab_enabled : 1;
52+
bool m_time_enabled : 1;
53+
bool m_space_enabled : 1;
54+
bool m_symtab_enabled : 1;
5555
run_time_clock::time_point m_start_cpu_time;
5656
std::chrono::steady_clock::time_point m_start_wall_time;
5757
long m_start_space;

0 commit comments

Comments
 (0)