This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
RE: [RFA] Handle BINOP_INTDIV in valarith.c
> -----Original Message-----
> From: gdb-patches-owner@sourceware.org [mailto:gdb-patches-
> owner@sourceware.org] On Behalf Of Tom Tromey
> Sent: Wednesday, January 23, 2008 7:30 PM
> To: Pierre Muller
> Cc: 'Eli Zaretskii'; gdb-patches@sourceware.org
> Subject: Re: [RFA] Handle BINOP_INTDIV in valarith.c
>
> >>>>> "Pierre" == Pierre Muller <muller@ics.u-strasbg.fr> writes:
>
> Pierre> This is the right thing to do for pascal,
> Pierre> but I don't know about the other languages:
> Pierre> do fortran, Ada, Modula-2 or java
> Pierre> allow 'a / b' for a or b of integer types?
>
> For Java the normal binary promotion rules apply to '/'.
>
> That is: if either a or b is double, the other is promoted to double.
> Then likewise for float.
Currently gdb does promotion to doubles
if one of the two is TYPE_CODE_FLT (i.e. any type of floating point,
except maybe the decimal floating that was recently introduced and
which code I did not look into yet).
> Then likewise for long.
> And finally, if none of those apply, both are promoted to int.
>
> So IOW, yes :)
But this means that like C and unlike pascal
'35 / 2' returns a integer of value 17, while for pascal
it does return a real of value 17.5.
> There are also special rules about certain integer divisions.
> Division by zero throws an exception, and MIN_INT/-1 is defined to be
> MIN_INT.
You probably ment MAX_INT here, no?
> In Java 5 there is also unboxing, but we never updated gdb to know
> about that.
I almost never used Java, so I have no idea what unboxing means...
Pierre Muller