public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/99945] New: missing maybe-uninitialized warning when using a cleanup function
@ 2021-04-06 21:28 vincent-gcc at vinc17 dot net
  2021-04-06 22:19 ` [Bug c/99945] " pinskia at gcc dot gnu.org
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: vincent-gcc at vinc17 dot net @ 2021-04-06 21:28 UTC (permalink / raw)
  To: gcc-bugs

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.

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2023-07-11 19:07 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-06 21:28 [Bug c/99945] New: missing maybe-uninitialized warning when using a cleanup function vincent-gcc at vinc17 dot net
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

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).