[gdb/exp] Fix assert when adding ptr to imaginary unit
I'm running into this assertion failure:
...
$ gdb -batch -ex "p (void *)0 - 5i"
gdbtypes.c:3430: internal-error: \
type* init_complex_type(const char*, type*): Assertion \
`target_type->code () == TYPE_CODE_INT \
|| target_type->code () == TYPE_CODE_FLT' failed.
A problem internal to GDB has been detected,
further debugging may prove unreliable.
...
This is a regression since commit c34e871466
"Implement complex arithmetic".
Before that commit we had:
...
(gdb) p (void *)0 - 5i
Argument to arithmetic operation not a number or boolean.
...
Fix this in complex_binop by throwing an error, such that we have:
...
(gdb) print (void *)0 - 5i
Argument to complex arithmetic operation not supported.
...
Tested on x86_64-linux.
gdb/ChangeLog:
2021-02-05 Tom de Vries <tdevries@suse.de>
PR exp/27265
* valarith.c (complex_binop): Throw an error if complex type can't
be created.
gdb/testsuite/ChangeLog:
2021-02-05 Tom de Vries <tdevries@suse.de>
PR exp/27265
* gdb.base/complex-parts.exp: Add tests.
This commit is contained in:
parent
d3b54e63f4
commit
ae71049661
6 changed files with 36 additions and 2 deletions
|
@ -2289,6 +2289,7 @@ extern struct type *init_float_type (struct objfile *, int, const char *,
|
|||
const struct floatformat **,
|
||||
enum bfd_endian = BFD_ENDIAN_UNKNOWN);
|
||||
extern struct type *init_decfloat_type (struct objfile *, int, const char *);
|
||||
extern bool can_create_complex_type (struct type *);
|
||||
extern struct type *init_complex_type (const char *, struct type *);
|
||||
extern struct type *init_pointer_type (struct objfile *, int, const char *,
|
||||
struct type *);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue