From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Andy Moreton Newsgroups: gmane.emacs.devel Subject: Re: Warnings in mingw64 build on emacs-28 branch Date: Sun, 07 Nov 2021 20:55:44 +0000 Message-ID: <86pmrblm7j.fsf@gmail.com> References: <86y260c9b8.fsf@gmail.com> <83fss880qc.fsf@gnu.org> <86zgqflu0g.fsf@gmail.com> <86tugnlpmo.fsf@gmail.com> <83tugn7n5f.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="1792"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (windows-nt) To: emacs-devel@gnu.org Cancel-Lock: sha1:4Oucedlv3O9taKxZDKwj/ZzJgK4= Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Sun Nov 07 21:56:38 2021 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mjpDS-0000KZ-7c for ged-emacs-devel@m.gmane-mx.org; Sun, 07 Nov 2021 21:56:38 +0100 Original-Received: from [::1] (port=44196 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mjpDQ-0007xk-Px for ged-emacs-devel@m.gmane-mx.org; Sun, 07 Nov 2021 15:56:36 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:41480) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mjpCi-0007H0-P8 for emacs-devel@gnu.org; Sun, 07 Nov 2021 15:55:52 -0500 Original-Received: from ciao.gmane.io ([116.202.254.214]:48208) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mjpCh-0007PR-1U for emacs-devel@gnu.org; Sun, 07 Nov 2021 15:55:52 -0500 Original-Received: from list by ciao.gmane.io with local (Exim 4.92) (envelope-from ) id 1mjpCf-0009q3-GO for emacs-devel@gnu.org; Sun, 07 Nov 2021 21:55:49 +0100 X-Injected-Via-Gmane: http://gmane.org/ Received-SPF: pass client-ip=116.202.254.214; envelope-from=ged-emacs-devel@m.gmane-mx.org; helo=ciao.gmane.io X-Spam_score_int: 5 X-Spam_score: 0.5 X-Spam_bar: / X-Spam_report: (0.5 / 5.0 requ) BAYES_00=-1.9, DKIM_ADSP_CUSTOM_MED=0.001, FORGED_GMAIL_RCVD=1, FREEMAIL_FORGED_FROMDOMAIN=0.249, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.248, NML_ADSP_CUSTOM_MED=0.9, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 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-mx.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.io gmane.emacs.devel:278986 Archived-At: On Sun 07 Nov 2021, Eli Zaretskii wrote: >> From: Andy Moreton >> Date: Sun, 07 Nov 2021 19:41:51 +0000 >> >> In set_frame_menubar from w32menu.c, this shows the warning: >> >> memcpy (previous_items, XVECTOR (f->menu_bar_vector)->contents, >> previous_menu_items_used * word_size); >> >> ...and this placates the compiler: >> >> memcpy (previous_items, xvector_contents (f->menu_bar_vector), >> previous_menu_items_used * word_size); > > That doesn't explain why we don't need the same in the other places > where memcpy and XVECTOR are used exactly like in w32menu.c, at least > AFAICT. I suspect that understanding that will require the expertise of someone with deep knowledge of gcc internals. > What your trick does is hide XVECTOR behind enough indirections for > the compiler to lose sight of what is going on. That is fine, but as > compilers look deeper and deeper, this trick will one day cease to be > enough. Thus, I'd still prefer to understand why the other calls of > memcpy don't trigger similar warnings. True, but hopefully by the time compilers can see past the indirections, they can also perform a correct analysis of shallower paths. Such accessor helpers are surely useful anyway, as they make the callsites clearer (and if used consistently, allow the implementation to be changed without changing the callers). AndyM