emacs-devel
[Top][All Lists]
Advanced

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

Re: Compiler warnings in dispnew.c


From: Po Lu
Subject: Re: Compiler warnings in dispnew.c
Date: Sun, 28 Nov 2021 19:02:36 +0800
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.60 (gnu/linux)

Eli Zaretskii <eliz@gnu.org> writes:

>> From: Po Lu <luangruo@yahoo.com>
>> Date: Sun, 28 Nov 2021 17:56:30 +0800
>> 
>> Building with checking, I get:
>> 
>>   CC       dispnew.o
>> In function ‘copy_row_except_pointers’,
>>     inlined from ‘assign_row’ at dispnew.c:1050:3,
>>     inlined from ‘mirror_make_current’ at dispnew.c:2761:3:
>> dispnew.c:1037:3: warning: ‘memcpy’ offset [48, 255] from the object at 
>> ‘current_row’ is out of the bounds of referenced subobject ‘x’ with type 
>> ‘int’ at offset 44 [-Warray-bounds]
>>  1037 |   memcpy (&to->x, &from->x, sizeof *to - off);
>>       |   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>> In file included from termchar.h:23,
>>                  from dispnew.c:28:
>> dispnew.c: In function ‘mirror_make_current’:
>> dispextern.h:885:7: note: subobject ‘x’ declared here
>>   885 |   int x, y;
>>       |       ^
>> 
>> I think it would be prudent to fix this, thanks.

> Do you understand the problem?  It looks like a compiler bug to me.
> We copy into the address of glyph_row->x and the size of the copy is
> the size of glyph_row structure minus the offset of x from the
> beginning.  So what is wrong with that? what am I missing?

I don't see anything wrong with it, but I think someone has to find a
way to silence the warning.

I could not find some reasonable way to do so that did not involve
#pragma GCC, which I think is not allowed in Emacs code (is that
correct?)

Thanks.

> When you say "building with checking", what do you mean, exactly?  Did
> you use some non-default warning switches, and if so, which ones?

I meant to say with '--enable-checking="yes,glyphs"'.

> And what version of GCC is that?

It's GCC 11.2.1.

Thanks.


reply via email to

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