From: Andrea Corallo <acorallo@gnu.org>
To: "Gerd Möllmann" <gerd.moellmann@gmail.com>
Cc: emacs-devel@gnu.org
Subject: Re: scratch/igc warning
Date: Wed, 26 Jun 2024 10:48:44 -0400 [thread overview]
Message-ID: <yp1msn7n4j7.fsf@fencepost.gnu.org> (raw)
In-Reply-To: <m2sewzwyxv.fsf@pro2.fritz.box> ("Gerd Möllmann"'s message of "Wed, 26 Jun 2024 16:39:24 +0200")
Gerd Möllmann <gerd.moellmann@gmail.com> writes:
> Andrea Corallo <acorallo@gnu.org> writes:
>
>> Hi,
>>
>> GCC 12.3 is giving me this warning building scratch/igc:
>>
>> ========
>> CC xfaces.o
>> In file included from /usr/include/string.h:535,
>> from ../lib/string.h:41,
>> from lisp.h:29,
>> from xfaces.c:226:
>> In function ‘memset’,
>> inlined from ‘make_realized_face’ at xfaces.c:4581:3,
>> inlined from ‘realize_gui_face’ at xfaces.c:6214:10,
>> inlined from ‘realize_face’ at xfaces.c:6124:12:
>> /usr/include/x86_64-linux-gnu/bits/string_fortified.h:59:10: warning: ‘__builtin_memset’ offset [164, 303] from the object at ‘face’ is out of the bounds of referenced subobject ‘id’ with type ‘int’ at offset 160 [-Warray-bounds]
>> 59 | return __builtin___memset_chk (__dest, __ch, __len,
>> | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>> 60 | __glibc_objsize0 (__dest));
>> | ~~~~~~~~~~~~~~~~~~~~~~~~~~
>> In file included from termhooks.h:27,
>> from frame.h:22,
>> from xfaces.c:229:
>> dispextern.h: In function ‘realize_face’:
>> dispextern.h:1730:7: note: subobject ‘id’ declared here
>> 1730 | int id;
>> | ^~
>> In function ‘memset’,
>> inlined from ‘make_realized_face’ at xfaces.c:4581:3,
>> inlined from ‘realize_tty_face’ at xfaces.c:6641:10,
>> inlined from ‘realize_face’ at xfaces.c:6126:12:
>> /usr/include/x86_64-linux-gnu/bits/string_fortified.h:59:10: warning: ‘__builtin_memset’ offset [164, 303] from the object at ‘face’ is out of the bounds of referenced subobject ‘id’ with type ‘int’ at offset 160 [-Warray-bounds]
>> 59 | return __builtin___memset_chk (__dest, __ch, __len,
>> | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>> 60 | __glibc_objsize0 (__dest));
>> | ~~~~~~~~~~~~~~~~~~~~~~~~~~
>> dispextern.h: In function ‘realize_face’:
>> dispextern.h:1730:7: note: subobject ‘id’ declared here
>> 1730 | int id;
>> | ^~
>> In function ‘memset’,
>> inlined from ‘make_realized_face’ at xfaces.c:4581:3,
>> inlined from ‘realize_face’ at xfaces.c:6130:14:
>> /usr/include/x86_64-linux-gnu/bits/string_fortified.h:59:10: warning: ‘__builtin_memset’ offset [164, 303] from the object at ‘face’ is out of the bounds of referenced subobject ‘id’ with type ‘int’ at offset 160 [-Warray-bounds]
>> 59 | return __builtin___memset_chk (__dest, __ch, __len,
>> | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>> 60 | __glibc_objsize0 (__dest));
>> | ~~~~~~~~~~~~~~~~~~~~~~~~~~
>> dispextern.h: In function ‘realize_face’:
>> dispextern.h:1730:7: note: subobject ‘id’ declared here
>> 1730 | int id;
>> | ^~
>> ========
>>
>> ATM don't know if it's a real issue or a false positive so I thought was
>> worth mentioning.
>
> Hm, that's this one, right?
>
> static struct face *
> make_realized_face (Lisp_Object *attr)
> {
> enum { off = offsetof (struct face, id) };
> #ifdef HAVE_MPS
> struct face *face = igc_make_face ();
> #else
> struct face *face = xmalloc (sizeof *face);
> #endif
> memcpy (face->lface, attr, sizeof face->lface);
> memset (&face->id, 0, sizeof *face - off);
> face->ascii_face = face;
>
> return face;
> }
>
> which we can rewrite, for MPS
>
> static struct face *
> make_realized_face (Lisp_Object *attr)
> {
> #ifdef HAVE_MPS
> struct face *face = igc_make_face ();
> memcpy (face->lface, attr, sizeof face->lface);
> #else
> enum { off = offsetof (struct face, id) };
> struct face *face = xmalloc (sizeof *face);
> memcpy (face->lface, attr, sizeof face->lface);
> memset (&face->id, 0, sizeof *face - off);
> #endif
> face->ascii_face = face;
>
> return face;
> }
>
> because igc returns something zero-initialized anyway. (I'll do that.).
Yep this clean the warning!
> But I wonder - does GCC 12 also complain for the non-MPS case?
It does not, my other tracked branches (master and emacs-30) are now
warning clean here with similar configurations.
With this fix scratch/igc will be warning clean as well 😀
Thanks
Andrea
next prev parent reply other threads:[~2024-06-26 14:48 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-26 14:08 scratch/igc warning Andrea Corallo
2024-06-26 14:31 ` Pip Cet
2024-06-26 14:43 ` Andrea Corallo
2024-06-26 15:45 ` Pip Cet
2024-06-26 14:39 ` Gerd Möllmann
2024-06-26 14:48 ` Andrea Corallo [this message]
2024-06-26 14:57 ` Gerd Möllmann
2024-06-26 16:25 ` scratch/igc lread testsuite error [was Re: scratch/igc warning] Andrea Corallo
2024-06-26 16:35 ` Gerd Möllmann
2024-06-27 7:01 ` Helmut Eller
2024-06-27 7:09 ` Gerd Möllmann
2024-06-27 12:09 ` Andrea Corallo
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=yp1msn7n4j7.fsf@fencepost.gnu.org \
--to=acorallo@gnu.org \
--cc=emacs-devel@gnu.org \
--cc=gerd.moellmann@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.