From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Richard Stallman Newsgroups: gmane.emacs.bugs Subject: bug#8545: issues with recent doprnt-related changes Date: Sat, 30 Apr 2011 17:03:47 -0400 Message-ID: References: <4DB50AB9.6060100@cs.ucla.edu> <83tydmaeo3.fsf@gnu.org> <4DB65FF1.5010003@cs.ucla.edu> <83aafb8p4a.fsf@gnu.org> <4DB8ABEA.3080503@cs.ucla.edu> <4DB8DAF8.7070408@cs.ucla.edu> <4DBB4E80.2020102@cs.ucla.edu> Reply-To: rms@gnu.org NNTP-Posting-Host: lo.gmane.org Content-Type: text/plain; charset=ISO-8859-15 X-Trace: dough.gmane.org 1304197624 18045 80.91.229.12 (30 Apr 2011 21:07:04 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Sat, 30 Apr 2011 21:07:04 +0000 (UTC) Cc: lekktu@gmail.com, 8545@debbugs.gnu.org To: Paul Eggert Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sat Apr 30 23:06:58 2011 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([140.186.70.17]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1QGHNP-0006LX-Nx for geb-bug-gnu-emacs@m.gmane.org; Sat, 30 Apr 2011 23:06:55 +0200 Original-Received: from localhost ([::1]:39818 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QGHNP-0007Fz-8v for geb-bug-gnu-emacs@m.gmane.org; Sat, 30 Apr 2011 17:06:55 -0400 Original-Received: from eggs.gnu.org ([140.186.70.92]:52535) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QGHNN-0007Fu-7p for bug-gnu-emacs@gnu.org; Sat, 30 Apr 2011 17:06:54 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QGHNM-0004Rv-2b for bug-gnu-emacs@gnu.org; Sat, 30 Apr 2011 17:06:53 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:45764) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QGHNL-0004Rp-TR for bug-gnu-emacs@gnu.org; Sat, 30 Apr 2011 17:06:52 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.69) (envelope-from ) id 1QGHLa-0004gT-7D; Sat, 30 Apr 2011 17:05:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Richard Stallman Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-To: owner@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 30 Apr 2011 21:05:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 8545 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 8545-submit@debbugs.gnu.org id=B8545.130419744217924 (code B ref 8545); Sat, 30 Apr 2011 21:05:02 +0000 Original-Received: (at 8545) by debbugs.gnu.org; 30 Apr 2011 21:04:02 +0000 Original-Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1QGHKb-0004f0-1Q for submit@debbugs.gnu.org; Sat, 30 Apr 2011 17:04:01 -0400 Original-Received: from fencepost.gnu.org ([140.186.70.10]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1QGHKX-0004en-Qf for 8545@debbugs.gnu.org; Sat, 30 Apr 2011 17:03:58 -0400 Original-Received: from rms by fencepost.gnu.org with local (Exim 4.71) (envelope-from ) id 1QGHKN-0008I1-9A; Sat, 30 Apr 2011 17:03:47 -0400 In-reply-to: <4DBB4E80.2020102@cs.ucla.edu> (message from Paul Eggert on Fri, 29 Apr 2011 16:49:20 -0700) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list Resent-Date: Sat, 30 Apr 2011 17:05:02 -0400 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-Received-From: 140.186.70.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:46116 Archived-At: >> If you assign i = INT_MAX + 1, the resulting behavior is undefined. > > The result is INT_MIN. We don't try to support any theoretical machine > where this would not be so. Those machines used to be theoretical, but they're in common use now. I assumed we were talking about type `int', but you did not explicitly say so. Touché -- but that just means we are talking at cross purposes. What I said about addition on type int is still valid. printf ("%d", INT_MAX+1); will output INT_MIN. Practical C code can no longer assume that integers always wrap around when doing integer arithmetic. I think that is the wrong interpretation of the facts. long foo (char *p, int i) { return &p[i + 1] - &p[i]; } On typical hosts where int is 32 bits, and long and char * are both 64 bits, most compilers optimize that "return" statement to "return 1;", even when I is INT_MAX and I + 1 therefore overflows. These compilers are therefore rejecting the notion that INT_MAX + 1 must always equal INT_MIN. i+1 is computed as an integer, but then it gets converted to a long. What happens here seems to be an issue about type conversion combined with addition -- not addition itself. These compilers are taking a strange liberty. Why isn't that a bug? -- Dr Richard Stallman President, Free Software Foundation 51 Franklin St Boston MA 02110 USA www.fsf.org, www.gnu.org Skype: No way! That's nonfree (freedom-denying) software. Use free telephony http://directory.fsf.org/category/tel/