[PATCH] Allow value repeat operator on references

Kevin Buettner kevinb@redhat.com
Fri Feb 9 19:14:36 GMT 2024


On Fri,  9 Feb 2024 14:04:51 +0100
Hannes Domani <ssbssa@yahoo.de> wrote:

> Currently it's not possible to use the value repeat operator on references:
> ```
> print ((int &) v_int_array_init[0])@2
> Only values in memory can be extended with '@'.
> ```
> 
> This seems like an unnecessary restriction, since it also prevents
> its use on iterators (which was the original reported problem):
> ```
> (gdb) p *it@2
> Only values in memory can be extended with '@'.
> ```
> 
> So this converts any references to the referenced value in value_repeat,
> making this possible:
> ```
> print ((int &) v_int_array_init[0])@2
> $1 = {10, 20}
> (gdb) p *it@2
> $2 = {1, 2}
> ```
> ---
>  gdb/testsuite/gdb.base/exprs.exp | 1 +
>  gdb/valops.c                     | 2 ++
>  2 files changed, 3 insertions(+)

LGTM.

Approved-by: Kevin Buettner <kevinb@redhat.com>



More information about the Gdb-patches mailing list