* [PATCH] Do not change type in get_discrete_low_bound
@ 2023-04-27 19:35 Tom Tromey
2023-04-28 16:07 ` Kevin Buettner
0 siblings, 1 reply; 2+ messages in thread
From: Tom Tromey @ 2023-04-27 19:35 UTC (permalink / raw)
To: gdb-patches; +Cc: Tom Tromey
get_discrete_low_bound has this code:
/* Set unsigned indicator if warranted. */
if (low >= 0)
type->set_is_unsigned (true);
It's bad to modify a type in a getter like this, so this patch removes
this code. FWIW I looked and this code has been there since at least
1999 (it was in the initial sourceware import).
Types in general would benefit from const-ification, which would
probably reveal more code like this, but I haven't attempted that.
Regression tested on x86-64 Fedora 36.
---
gdb/gdbtypes.c | 4 ----
1 file changed, 4 deletions(-)
diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c
index 6af59351b76..c8d5314bce7 100644
--- a/gdb/gdbtypes.c
+++ b/gdb/gdbtypes.c
@@ -1084,10 +1084,6 @@ get_discrete_low_bound (struct type *type)
low = type->field (i).loc_enumval ();
}
- /* Set unsigned indicator if warranted. */
- if (low >= 0)
- type->set_is_unsigned (true);
-
return low;
}
else
--
2.39.1
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] Do not change type in get_discrete_low_bound
2023-04-27 19:35 [PATCH] Do not change type in get_discrete_low_bound Tom Tromey
@ 2023-04-28 16:07 ` Kevin Buettner
0 siblings, 0 replies; 2+ messages in thread
From: Kevin Buettner @ 2023-04-28 16:07 UTC (permalink / raw)
To: Tom Tromey via Gdb-patches; +Cc: Tom Tromey
On Thu, 27 Apr 2023 13:35:15 -0600
Tom Tromey via Gdb-patches <gdb-patches@sourceware.org> wrote:
> get_discrete_low_bound has this code:
>
> /* Set unsigned indicator if warranted. */
> if (low >= 0)
> type->set_is_unsigned (true);
>
> It's bad to modify a type in a getter like this, so this patch removes
> this code. FWIW I looked and this code has been there since at least
> 1999 (it was in the initial sourceware import).
LGTM.
Reviewed-by: Kevin Buettner <kevinb@redhat.com>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2023-04-28 16:07 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-04-27 19:35 [PATCH] Do not change type in get_discrete_low_bound Tom Tromey
2023-04-28 16:07 ` Kevin Buettner
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).