Re: [PATCH] Expand bitpos to LONGEST to allow access to large offsets within a struct

Jan Kratochvil
2012-02-21T21:02:53Z

On Mon, 20 Feb 2012 14:28:24 +0100, Siddhesh Poyarekar wrote:
> @@ -1318,13 +1318,13 @@ gen_bitfield_ref (struct expression *exp, struct agent_expr *ax,
>
> /* The first and one-after-last bits in the field, but rounded down
> and up to byte boundaries. */
> - int bound_start = (start / TARGET_CHAR_BIT) * TARGET_CHAR_BIT;
> - int bound_end = (((end + TARGET_CHAR_BIT - 1)
> + LONGEST bound_start = (start / TARGET_CHAR_BIT) * TARGET_CHAR_BIT;
> + LONGEST bound_end = (((end + TARGET_CHAR_BIT - 1)
> / TARGET_CHAR_BIT)
> * TARGET_CHAR_BIT);

In these cases one needs to also reindent the two TARGET_CHAR_BIT lines to
properly match their columns.

On top of Tom's comments - have you verified you caught all the cases?
In these cases I use some
typedef struct { LONGEST x; } LONGESTT;

which is compatible for assignment only with itself catching all the cases.
Unfortunately one needs to adjust by hand all the arithmetic operations just
for the purpose of this verification.

I guess there exist better static analysis tools for that.

Thanks,
Jan