public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "vincent-gcc at vinc17 dot net" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c/99945] New: missing maybe-uninitialized warning when using a cleanup function
Date: Tue, 06 Apr 2021 21:28:17 +0000	[thread overview]
Message-ID: <bug-99945-4@http.gcc.gnu.org/bugzilla/> (raw)

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99945

            Bug ID: 99945
           Summary: missing maybe-uninitialized warning when using a
                    cleanup function
           Product: gcc
           Version: 11.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: vincent-gcc at vinc17 dot net
  Target Milestone: ---

Consider the following testcase:

int foo1 (void);
int foo2 (int);

#ifdef D
#define N
#else
#define N !
#endif

int bar (void)
{
  int i;
  auto void cf (int *t) { foo2 (i); }
  int t __attribute__ ((cleanup (cf)));

  t = 0;

  if (foo1 ())
    i = foo1 ();

  i = N foo1 () || i;
  foo2 (i);

  return 0;
}

With a GCC snapshot built a few hours ago from the master branch on x86_64:

cventin% gcc --version
gcc (GCC) 11.0.1 20210406 (experimental)

cventin% gcc -Werror=maybe-uninitialized -O2 -c file.c                         
cventin% gcc -Werror=maybe-uninitialized -O2 -c file.c -DD
cventin% gcc -Werror=maybe-uninitialized -O2 -c file.c -fsanitize=undefined
cventin% gcc -Werror=maybe-uninitialized -O2 -c file.c -fsanitize=undefined -DD
file.c: In function ‘bar’:
file.c:21:17: error: ‘FRAME.1.i’ may be used uninitialized
[-Werror=maybe-uninitialized]
   21 |   i = N foo1 () || i;
      |         ~~~~~~~~^~~~
file.c:10:5: note: ‘FRAME.1’ declared here
   10 | int bar (void)
      |     ^~~
cc1: some warnings being treated as errors

Except in the last case, the warning is missing, though -fsanitize=undefined
should have no influence, and whether one does "! foo1 ()" or "foo1 ()" should
have no effects either.

             reply	other threads:[~2021-04-06 21:28 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-06 21:28 vincent-gcc at vinc17 dot net [this message]
2021-04-06 22:19 ` [Bug c/99945] " pinskia at gcc dot gnu.org
2021-04-07  0:01 ` vincent-gcc at vinc17 dot net
2021-04-07  0:08 ` vincent-gcc at vinc17 dot net
2021-04-07  0:09 ` [Bug sanitizer/99945] " msebor at gcc dot gnu.org
2021-04-07  7:29 ` rguenth at gcc dot gnu.org
2021-04-07 15:23 ` msebor at gcc dot gnu.org
2023-07-11 19:02 ` [Bug sanitizer/99945] missing maybe-uninitialized warning when using nested function vs SRA pinskia at gcc dot gnu.org
2023-07-11 19:07 ` [Bug tree-optimization/99945] " pinskia at gcc dot gnu.org

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=bug-99945-4@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@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).