From: Andreas Schwab <schwab@linux-m68k.org>
To: Eli Zaretskii <eliz@gnu.org>
Cc: "Óscar Fuentes" <ofv@wanadoo.es>, emacs-devel@gnu.org
Subject: Re: warnings compiling emacs28 with gcc 12.1
Date: Thu, 28 Jul 2022 20:31:59 +0200 [thread overview]
Message-ID: <87sfmlqeao.fsf@igel.home> (raw)
In-Reply-To: <83lesd87e8.fsf@gnu.org> (Eli Zaretskii's message of "Thu, 28 Jul 2022 20:38:23 +0300")
On Jul 28 2022, Eli Zaretskii wrote:
>> From: Óscar Fuentes <ofv@wanadoo.es>
>> Date: Thu, 28 Jul 2022 19:12:00 +0200
>>
>> Eli Zaretskii <eliz@gnu.org> writes:
>>
>> >> and there's another one about free that looks a bit scary:
>> >>
>> >> alloc.c: In function ‘lisp_free’:
>> >> alloc.c:1052:3: warning: pointer ‘block’ used after ‘free’ [-Wuse-after-free]
>> >> 1052 | mem_delete (mem_find (block));
>> >> | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>> >> alloc.c:1050:3: note: call to ‘free’ here
>> >> 1050 | free (block);
>> >> | ^~~~~~~~~~~~
>> >
>> > Another nonsense. Look in mem_find, and you will see that it uses its
>> > argument as just a number, it never dereferences it.
>>
>> The warning is not about dereferencing the pointer.
>
> What other problems could be caused by using it after freeing it?
Evan just reading the value of a pointer after free is undefined. If
you want to preserve its bit pattern, you need to convert it to an
integer type before the call to free.
--
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510 2552 DF73 E780 A9DA AEC1
"And now for something completely different."
next prev parent reply other threads:[~2022-07-28 18:31 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-07-28 3:32 warnings compiling emacs28 with gcc 12.1 Jose A. Ortega Ruiz
2022-07-28 17:02 ` Eli Zaretskii
2022-07-28 17:12 ` Óscar Fuentes
2022-07-28 17:38 ` Eli Zaretskii
2022-07-28 18:31 ` Andreas Schwab [this message]
2022-07-28 18:35 ` Óscar Fuentes
2022-07-28 17:23 ` Jose A. Ortega Ruiz
2022-07-28 18:13 ` Lars Ingebrigtsen
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=87sfmlqeao.fsf@igel.home \
--to=schwab@linux-m68k.org \
--cc=eliz@gnu.org \
--cc=emacs-devel@gnu.org \
--cc=ofv@wanadoo.es \
/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.