This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [BUG] BINOP_DIV and ptyp command


On Jan 28, 2008 10:41 PM, Joel Brobecker <brobecker@adacore.com> wrote:
> > I may be missing something, but it seems like special casing
> > EVAL_AVOID_SIDE_EFFECTS for DIV/MOD/REM is no longer useful here
>
> I don't think this is right. EVAL_AVOID_SIDE_EFFECTS is used when
> computing the actual value is not needed. For instance, when you do
> "ptype", the expression is evaluated in that mode.  So when you do
> "ptype 3 div 2", we don't do the division, we just know that we're only
> interested in the type of result.  So the expression evaluator will
> return a struct value of the correct type but with a bogus contents,
> instead of doing the division, only to discard the result down the road.
>
> So the code you suggested we remove is useful.

As I say, if the intent is to avoid the call to error(), I'd expect to
see tests for 1 >> 3.0, etc.  That will throw error ("Integer-only
operation on floating point number").  If that code is the code that's
missing, fine, except that I'd also change the comments describing
what EVAL_AVOID_SIDE_EFFECTS is for:

    EVAL_AVOID_SIDE_EFFECTS     /* Don't modify any variables or
                                   call any functions.  The value
                                   returned will have the correct
                                   type, and will have an
                                   approximately correct lvalue
                                   type (inaccuracy: anything that is
                                   listed as being in a register in
                                   the function in which it was
                                   declared will be lval_register).  */

One can believe the intent that side effects in this particular case
includes throwing error(), but the docs should be explicit on this.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]