Re: PATCH: Problem union comparision in TUI

Eli Zaretskii
2005-10-19T09:15:14Z

> Date: Mon, 17 Oct 2005 15:51:21 +0100
> From: Andrew STUBBS <andrew.stubbs@st.com>
>
> --- src.orig/gdb/tui/tui-data.h 2004-03-13 14:14:01.000000000 +0000
> +++ src/gdb/tui/tui-data.h 2005-10-17 14:21:23.000000000 +0100
> @@ -149,7 +149,7 @@ enum tui_register_display_type
> /* Structure describing source line or line address */
> union tui_line_or_address
> {
> - int line_no;
> + CORE_ADDR line_no;
> CORE_ADDR addr;
> };

IMHO, a better way of fixing this would be to change
tui_line_or_address to be a struct as follows:

/* Structure describing source line or line address */
struct tui_line_or_address
{
unsigned char what
union {
int line_no;
CORE_ADDR addr;
} u;
};

and then fill the `what' member as appropriate and use the right part
of the union in the comparison.