public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jakub Jelinek <jakub@redhat.com>
To: Andrew MacLeod <amacleod@redhat.com>
Cc: gcc-patches <gcc-patches@gcc.gnu.org>
Subject: Re: [PATCH] PR tree-optimization/109238 - Ranger cache dominator queries should ignore backedges.
Date: Thu, 23 Mar 2023 20:10:36 +0100	[thread overview]
Message-ID: <ZBykLNA2n8Ru1iVA@tucnak> (raw)
In-Reply-To: <96146be5-a7aa-23fb-0052-d2d81ff60c08@redhat.com>

On Thu, Mar 23, 2023 at 02:37:01PM -0400, Andrew MacLeod via Gcc-patches wrote:
> PS I have not managed to produce a reduced testcase yet.. If I do I will
> supply it.

Here is one:
/* PR tree-optimization/10923 */
/* { dg-do compile } */
/* { dg-options "-O2 -Wall" } */

void foo (void *) __attribute__((noreturn));
void bar (void *);

void
baz (void *p)
{
  void *c = __builtin_realloc (p, 16);
  if (c)
    foo (c);
  for (;;)
    bar (__builtin_realloc (p, 8));	/* { dg-bogus "pointer 'p' may be used after '__builtin_realloc'" } */
}

Better than what I've attached in the PR, because this one actually
doesn't contain a leak.  If first realloc fails, foo can still free it and
exit, if first realloc fails, bar will be called with result of second
realloc and can exit there too.  Oh, it would need global variable from
caller to pas p to it in case even the second realloc fails.

	Jakub


  reply	other threads:[~2023-03-23 19:10 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-23 18:37 Andrew MacLeod
2023-03-23 19:10 ` Jakub Jelinek [this message]
2023-03-24  7:03 ` Richard Biener

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=ZBykLNA2n8Ru1iVA@tucnak \
    --to=jakub@redhat.com \
    --cc=amacleod@redhat.com \
    --cc=gcc-patches@gcc.gnu.org \
    /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.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).