From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 27919 invoked by alias); 29 Jan 2008 07:35:58 -0000 Received: (qmail 27904 invoked by uid 22791); 29 Jan 2008 07:35:57 -0000 X-Spam-Check-By: sourceware.org Received: from ics.u-strasbg.fr (HELO ics.u-strasbg.fr) (130.79.112.250) by sourceware.org (qpsmtpd/0.31) with ESMTP; Tue, 29 Jan 2008 07:35:35 +0000 Received: from ICSMULLER (unknown [130.79.244.152]) by ics.u-strasbg.fr (Postfix) with ESMTP id 384C318701C; Tue, 29 Jan 2008 08:41:56 +0100 (CET) From: "Pierre Muller" To: "'Joel Brobecker'" , "'Doug Evans'" Cc: "'GDB Patches'" References: <002301c85c12$a73a4640$f5aed2c0$@u-strasbg.fr> <20080129064148.GB16288@adacore.com> In-Reply-To: <20080129064148.GB16288@adacore.com> Subject: RE: [BUG] BINOP_DIV and ptyp command Date: Tue, 29 Jan 2008 07:51:00 -0000 Message-ID: <000e01c86249$89870100$9c950300$@u-strasbg.fr> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Mailer: Microsoft Office Outlook 12.0 Content-Language: en-us Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2008-01/txt/msg00670.txt.bz2 The code might be useful, but it returns wrong results... Because if you go the the value_binop code, you will see that there are some typecast that do change the result type of BINOP_DIV. The problem with Doug's code is that the error('Division by zero') will be thrown even for a ptyp command, which is indeed wrong, but how do we fix the bug then? By the way, Doug patch is also not correct because even though the signed integer division is caught in value_binop, the corresponding unsigned code is still missing the same check. The patch below fixes 'p 1/0U' output, without the patch my cygwin gdb just freezes! OK to commit? ChangeLog entry: 2008-01-29 Pierre Muller * valarith.c (value_binop): Handle unsigned integer division by zero. Index: gdb/valarith.c =================================================================== RCS file: /cvs/src/src/gdb/valarith.c,v retrieving revision 1.54 diff -u -p -r1.54 valarith.c --- gdb/valarith.c 18 Jan 2008 17:07:40 -0000 1.54 +++ gdb/valarith.c 29 Jan 2008 07:23:43 -0000 @@ -1035,7 +1035,10 @@ value_binop (struct value *arg1, struct case BINOP_DIV: case BINOP_INTDIV: - v = v1 / v2; + if (v2 != 0) + v = v1 / v2; + else + error (_("Division by zero")); break; case BINOP_EXP: