[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Warnings in mingw64 build on emacs-28 branch

From: Andy Moreton
Subject: Re: Warnings in mingw64 build on emacs-28 branch
Date: Sun, 07 Nov 2021 20:55:44 +0000
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (windows-nt)

On Sun 07 Nov 2021, Eli Zaretskii wrote:

>> From: Andy Moreton <andrewjmoreton@gmail.com>
>> 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

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).


reply via email to

[Prev in Thread] Current Thread [Next in Thread]