From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Paul Eggert Newsgroups: gmane.emacs.bugs Subject: bug#8545: issues with recent doprnt-related changes Date: Fri, 29 Apr 2011 16:49:20 -0700 Organization: UCLA Computer Science Department Message-ID: <4DBB4E80.2020102@cs.ucla.edu> 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> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-15 Content-Transfer-Encoding: 7bit X-Trace: dough.gmane.org 1304122025 7713 80.91.229.12 (30 Apr 2011 00:07:05 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Sat, 30 Apr 2011 00:07:05 +0000 (UTC) Cc: lekktu@gmail.com, 8545@debbugs.gnu.org To: rms@gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sat Apr 30 02:06:56 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 1QFxi4-0003Ec-4F for geb-bug-gnu-emacs@m.gmane.org; Sat, 30 Apr 2011 02:06:56 +0200 Original-Received: from localhost ([::1]:40785 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QFxi3-0005xq-JV for geb-bug-gnu-emacs@m.gmane.org; Fri, 29 Apr 2011 20:06:55 -0400 Original-Received: from eggs.gnu.org ([140.186.70.92]:56772) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QFxi0-0005xa-Hw for bug-gnu-emacs@gnu.org; Fri, 29 Apr 2011 20:06:53 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QFxhz-00022U-FB for bug-gnu-emacs@gnu.org; Fri, 29 Apr 2011 20:06:52 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:59572) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QFxhz-00022I-BO for bug-gnu-emacs@gnu.org; Fri, 29 Apr 2011 20:06:51 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.69) (envelope-from ) id 1QFxRj-0008Me-1B; Fri, 29 Apr 2011 19:50:03 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Paul Eggert Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-To: owner@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 29 Apr 2011 23:50: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.130412097032110 (code B ref 8545); Fri, 29 Apr 2011 23:50:02 +0000 Original-Received: (at 8545) by debbugs.gnu.org; 29 Apr 2011 23:49:30 +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 1QFxRB-0008Lr-Bc for submit@debbugs.gnu.org; Fri, 29 Apr 2011 19:49:29 -0400 Original-Received: from smtp.cs.ucla.edu ([131.179.128.62]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1QFxR9-0008Lf-3c for 8545@debbugs.gnu.org; Fri, 29 Apr 2011 19:49:28 -0400 Original-Received: from localhost (localhost.localdomain [127.0.0.1]) by smtp.cs.ucla.edu (Postfix) with ESMTP id 7BF0839E8106; Fri, 29 Apr 2011 16:49:21 -0700 (PDT) X-Virus-Scanned: amavisd-new at smtp.cs.ucla.edu Original-Received: from smtp.cs.ucla.edu ([127.0.0.1]) by localhost (smtp.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id GU65Fyozg0+U; Fri, 29 Apr 2011 16:49:20 -0700 (PDT) Original-Received: from [131.179.64.200] (Penguin.CS.UCLA.EDU [131.179.64.200]) by smtp.cs.ucla.edu (Postfix) with ESMTPSA id E382839E80F2; Fri, 29 Apr 2011 16:49:20 -0700 (PDT) User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.15) Gecko/20110307 Fedora/3.1.9-0.39.b3pre.fc14 Thunderbird/3.1.9 In-Reply-To: X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list Resent-Date: Fri, 29 Apr 2011 19:50:03 -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:46086 Archived-At: On 04/29/11 05:28, Richard Stallman wrote: > We are concerned with standards insofar as they matter in practice > for the convenience and reliability of our software. Yes, of course, I should have made that clearer. Standards are our tools, not our masters. >> 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. Practical C code can no longer assume that integers always wrap around when doing integer arithmetic. For example: 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. Although FOO is contrived, a lot of complicated code in Emacs mixes int and long and pointer arithmetic, and it's inevitable that compilers are doing optimizations like the above when they compile Emacs. We cannot simply declare that INT_MAX + 1 must always be INT_MIN, because that's not how compilers actually work these days. What we need is good advice for programmers in this area, so that they can write C code that is portable in practice. This advice shouldn't be too conservative, because that would discourage useful programs. Nor should it be too loosey-goosey, because that would encourage buggy programs. Nor should it be complicated, because that would confuse people and waste their time. It is not easy to come up with advice that satisfies all three constraints.