Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Tom de Vries <tdevries@suse.de>
To: Tom Tromey <tom@tromey.com>
Cc: gdb-patches@sourceware.org
Subject: Re: [PATCH][gdb/exp] Fix assert when adding ptr to imaginary unit
Date: Fri, 5 Feb 2021 11:05:31 +0100	[thread overview]
Message-ID: <cab310a2-1881-d084-203d-da9c3bc60762@suse.de> (raw)
In-Reply-To: <cc227b95-2567-e2b0-e434-f2ae0398f023@suse.de>

On 1/29/21 8:10 AM, Tom de Vries wrote:
> On 1/29/21 8:04 AM, Tom de Vries wrote:
>> On 1/28/21 3:08 PM, Tom Tromey wrote:
>>>>>>>> "Tom" == Tom de Vries <tdevries@suse.de> writes:
>>>
>>> Tom> 2021-01-28  Tom de Vries  <tdevries@suse.de>
>>>
>>> Tom> 	PR exp/27265
>>> Tom> 	* valarith.c (scalar_binop): Don't call complex_binop unless
>>> Tom> 	arguments are either complex or can be casted to complex.
>>>
>>> Thanks for doing this.
>>>
>>> Tom> +  if ((type1->code () == TYPE_CODE_COMPLEX
>>> Tom> +       && (type2->code () == TYPE_CODE_COMPLEX
>>> Tom> +	   || type2->code () == TYPE_CODE_INT
>>> Tom> +	   || type2->code () == TYPE_CODE_FLT))
>>> Tom> +      || ((type2->code () == TYPE_CODE_COMPLEX
>>> Tom> +	   && (type1->code () == TYPE_CODE_COMPLEX
>>> Tom> +	       || type1->code () == TYPE_CODE_INT
>>> Tom> +	       || type1->code () == TYPE_CODE_FLT))))
>>> Tom>      return complex_binop (arg1, arg2, op);
>>>
>>> Maybe it should use is_floating_type || is_integral_type instead?
>>> is_scalar_type sounds like it should be right but does something really
>>> different instead.  That function looks suspect to me.
>>>
>>> This approach would still rule out fixed point.  I'm not sure if that's
>>> ok to do though.
>>>
>>> Also weirdly, is_fixed_point_type looks through TYPE_CODE_RANGE (seems
>>> reasonable) but is_integral_type does not (seems wrong).
>>>
>>
>> I managed to create an example using TYPE_CODE_BOOL that used to work
>> but was broken by this patch, added it to the tests in the patch.
>>
>> I've now gone a different route: instead of trying to narrow down when
>> complex_binop can be called, detect the error situation in complex_bin
>> and throw an error.
>>
>> That avoids speculation about what type is left after promotion.
>> Instead, we just check the type after promotion.
>>
>> WDYT?
> 
> And FWIW, this WIP follow-up patch enables decimal float complex well
> enough to do "print (_Decimal32)0 + 5i".
> 

Filed as PR27350 - Support complex decimal float (
https://sourceware.org/bugzilla/show_bug.cgi?id=27350 ).

Thanks,
- Tom

  reply	other threads:[~2021-02-05 10:05 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-28 13:06 Tom de Vries
2021-01-28 14:08 ` Tom Tromey
2021-01-29  7:04   ` Tom de Vries
2021-01-29  7:10     ` Tom de Vries
2021-02-05 10:05       ` Tom de Vries [this message]
2021-02-05  9:57     ` Tom de Vries

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=cab310a2-1881-d084-203d-da9c3bc60762@suse.de \
    --to=tdevries@suse.de \
    --cc=gdb-patches@sourceware.org \
    --cc=tom@tromey.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox