diff options
author | Tom de Vries <tdevries@suse.de> | 2021-02-05 10:56:39 +0100 |
---|---|---|
committer | Tom de Vries <tdevries@suse.de> | 2021-02-05 10:56:39 +0100 |
commit | ae7104966177c7bcb7bef9e1445489d9d2f97f06 (patch) | |
tree | 0db06bfbce6489d5145e0433da37b037cf15f451 /gdb/valarith.c | |
parent | d3b54e63f4866551953a03f512049741b0e776c4 (diff) | |
download | fsf-binutils-gdb-ae7104966177c7bcb7bef9e1445489d9d2f97f06.zip fsf-binutils-gdb-ae7104966177c7bcb7bef9e1445489d9d2f97f06.tar.gz fsf-binutils-gdb-ae7104966177c7bcb7bef9e1445489d9d2f97f06.tar.bz2 |
[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 c34e8714662 "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.
Diffstat (limited to 'gdb/valarith.c')
-rw-r--r-- | gdb/valarith.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/gdb/valarith.c b/gdb/valarith.c index 3150309..299a99f 100644 --- a/gdb/valarith.c +++ b/gdb/valarith.c @@ -1076,6 +1076,9 @@ complex_binop (struct value *arg1, struct value *arg2, enum exp_opcode op) struct type *comp_type = promotion_type (value_type (arg1_real), value_type (arg2_real)); + if (!can_create_complex_type (comp_type)) + error (_("Argument to complex arithmetic operation not supported.")); + arg1_real = value_cast (comp_type, arg1_real); arg1_imag = value_cast (comp_type, arg1_imag); arg2_real = value_cast (comp_type, arg2_real); |