From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.devel Subject: Re: ptrdiff_t misuse [was :Re: (empty)] Date: Fri, 29 Jun 2012 13:07:33 -0400 Message-ID: References: <83lij66yq9.fsf@gnu.org> <4FEDB953.1010800@yandex.ru> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: dough.gmane.org 1341022119 20626 80.91.229.3 (30 Jun 2012 02:08:39 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Sat, 30 Jun 2012 02:08:39 +0000 (UTC) Cc: Paul Eggert , emacs-devel@gnu.org To: Dmitry Antipov Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sat Jun 30 04:08:38 2012 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1Skn70-0006g5-4J for ged-emacs-devel@m.gmane.org; Sat, 30 Jun 2012 04:08:38 +0200 Original-Received: from localhost ([::1]:36480 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Skn70-0007Rr-1U for ged-emacs-devel@m.gmane.org; Fri, 29 Jun 2012 22:08:38 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:50113) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Skn6x-0007Rm-Cn for emacs-devel@gnu.org; Fri, 29 Jun 2012 22:08:36 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Skn6v-000617-La for emacs-devel@gnu.org; Fri, 29 Jun 2012 22:08:34 -0400 Original-Received: from pruche.dit.umontreal.ca ([132.204.246.22]:37654) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Skn6v-00060z-I0 for emacs-devel@gnu.org; Fri, 29 Jun 2012 22:08:33 -0400 Original-Received: from fmsmemgm.homelinux.net (lechon.iro.umontreal.ca [132.204.27.242]) by pruche.dit.umontreal.ca (8.14.1/8.14.1) with ESMTP id q5U28MZl006597; Fri, 29 Jun 2012 22:08:22 -0400 Original-Received: by fmsmemgm.homelinux.net (Postfix, from userid 20848) id 0F2E6AE50E; Fri, 29 Jun 2012 13:07:34 -0400 (EDT) In-Reply-To: <4FEDB953.1010800@yandex.ru> (Dmitry Antipov's message of "Fri, 29 Jun 2012 18:18:59 +0400") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.1.50 (gnu/linux) X-NAI-Spam-Flag: NO X-NAI-Spam-Threshold: 5 X-NAI-Spam-Score: 0 X-NAI-Spam-Rules: 1 Rules triggered RV4265=0 X-NAI-Spam-Version: 2.2.0.9309 : core <4265> : streams <776296> : uri <1152833> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 132.204.246.22 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:151308 Archived-At: > Argh, I misuse them against window_end_pos and window_end_bytepos, > which are positions in a buffer and so ptrdiff_t :-(. This should > be reverted. Not only there: hscroll and min_hscroll should be `int' fields. And similarly Paul's "fix" to use: ptrdiff_t clipped_arg = clip_to_bounds (- w->hscroll, requested_arg, HSCROLL_MAX - w->hscroll); should be reverted. Really, if someone ever bumps into a problem because of such an overflow, I'll be *super* happy, because it means that all the performance problems we get with long lines have been fixed. Properly catching/handling integer overflows is a good idea, but C makes it much too painful in general, so we don't want to do it in unrealistic corner cases, preferring code cleanliness. Stefan