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: [RFC, PATCH] shrink struct vectorlike_header #2 Date: Thu, 08 Nov 2012 09:03:13 -0500 Message-ID: References: <50766A2C.8070705@yandex.ru> <50994448.6020602@yandex.ru> <509A76F7.3050105@yandex.ru> <509B4246.2050203@cs.ucla.edu> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1352383409 17437 80.91.229.3 (8 Nov 2012 14:03:29 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 8 Nov 2012 14:03:29 +0000 (UTC) Cc: Dmitry Antipov , Emacs development discussions To: Paul Eggert Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Thu Nov 08 15:03:37 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 1TWShl-0004g7-Af for ged-emacs-devel@m.gmane.org; Thu, 08 Nov 2012 15:03:37 +0100 Original-Received: from localhost ([::1]:53183 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TWShc-0008KQ-1O for ged-emacs-devel@m.gmane.org; Thu, 08 Nov 2012 09:03:28 -0500 Original-Received: from eggs.gnu.org ([208.118.235.92]:42815) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TWShY-0008KI-Vj for emacs-devel@gnu.org; Thu, 08 Nov 2012 09:03:25 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TWShP-0006EH-8s for emacs-devel@gnu.org; Thu, 08 Nov 2012 09:03:24 -0500 Original-Received: from ironport2-out.teksavvy.com ([206.248.154.182]:40200) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TWShP-0006Ds-4n for emacs-devel@gnu.org; Thu, 08 Nov 2012 09:03:15 -0500 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Av0EAG6Zu0/O+LEi/2dsb2JhbABEDrQDgQiCFQEBBAFWIwULCzQSFBgNJIgcBboJkEQDiEKVd4R6gViCMFc X-IronPort-AV: E=Sophos;i="4.75,637,1330923600"; d="scan'208";a="206731354" Original-Received: from 206-248-177-34.dsl.teksavvy.com (HELO pastel.home) ([206.248.177.34]) by ironport2-out.teksavvy.com with ESMTP/TLS/ADH-AES256-SHA; 08 Nov 2012 09:03:13 -0500 Original-Received: by pastel.home (Postfix, from userid 20848) id 7AABA59780; Thu, 8 Nov 2012 09:03:13 -0500 (EST) In-Reply-To: <509B4246.2050203@cs.ucla.edu> (Paul Eggert's message of "Wed, 07 Nov 2012 21:25:26 -0800") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux) X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 206.248.154.182 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:154732 Archived-At: >> I doubt (*(struct Lisp_Vector **)((char *) v + header_size)) >> is any better. I guess it just defeats gcc's detection of the problem. > Casting through char * is better, because the C standard > says that a compiler cannot do type-based alias inferencing > in the presence of char * pointers. That's so backwards: rather than force people to use low-level fiddly code, why can't they say "oh wait, you're doing some funny cast, let's be more conservative with type-based aliasing, as if the code used char*". > I presume this is why GCC generates all those warnings when we don't > use char * -- GCC is warning us that it may be doing optimizations > that will crash our code. IOW it's telling us "beware that even though I have here evidence that type-based alias analysis is unsafe for your code, I'll go ahead and use it anyway even though I know how not to use it since I have to do that when you use char* casts!". Nice. > struct Lisp_Vector > { > struct vectorlike_header header; > union > { > Lisp_Object contents[1]; > struct Lisp_Vector *next; > } u; > }; Yes, that'd be better. Stefan