public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug analyzer/105961] New: -Wanalyzer-use-of-uninitialized-value false positive after "= {0}"
@ 2022-06-13 20:18 eggert at cs dot ucla.edu
  2022-06-13 20:27 ` [Bug analyzer/105961] " dmalcolm at gcc dot gnu.org
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: eggert at cs dot ucla.edu @ 2022-06-13 20:18 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 105961
           Summary: -Wanalyzer-use-of-uninitialized-value false positive
                    after "= {0}"
           Product: gcc
           Version: 12.1.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: analyzer
          Assignee: dmalcolm at gcc dot gnu.org
          Reporter: eggert at cs dot ucla.edu
  Target Milestone: ---

This is gcc (GCC) 12.1.1 20220507 (Red Hat 12.1.1-1) on x86-64. I do not
observe the bug with gcc-12 (Ubuntu 12-20220319-1ubuntu1) 12.0.1 20220319
(experimental) [master r12-7719-g8ca61ad148f] on x86-64.

Compile the attached program (derived from bleeding-edge Emacs) with:

gcc -O2 -S -fanalyzer t.i

GCC complains:

In function ‘dump_mmap_release’,
    inlined from ‘pdumper_load’ at t.i:50527:5:
t.i:49512:10: warning: use of uninitialized value ‘sections[i].release’
[CWE-457] [-Wanalyzer-use-of-uninitialized-value]
49512 |   if (map->release)
      |       ~~~^~~~~~~~~
  ‘pdumper_load’: events 1-9
    |
    |50318 | pdumper_load (const char *dump_filename, char *argv0)
    |      | ^~~~~~~~~~~~
    |      | |
    |      | (1) entry to ‘pdumper_load’
    |......
    |50331 |   struct dump_memory_map sections[NUMBER_DUMP_SECTIONS] = { 0 };
    |      |                          ~~~~~~~~
    |      |                          |
    |      |                          (2) region created on stack here
    |......


The region is obviously initialized, via the "= { 0 }" at the end. The
following change pacifies GCC, but should not be necessary.

--- t.i 2022-06-13 13:06:59.000000000 -0700
+++ u.i 2022-06-13 13:09:18.000000000 -0700
@@ -50329,6 +50329,7 @@
   struct dump_header header_buf = { 0 };
   struct dump_header *header = &header_buf;
   struct dump_memory_map sections[NUMBER_DUMP_SECTIONS] = { 0 };
+  memset (sections, 0, sizeof sections);

   const struct timespec start_time = current_timespec ();
   char *dump_filename_copy;

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

end of thread, other threads:[~2024-02-16 14:13 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-13 20:18 [Bug analyzer/105961] New: -Wanalyzer-use-of-uninitialized-value false positive after "= {0}" eggert at cs dot ucla.edu
2022-06-13 20:27 ` [Bug analyzer/105961] " dmalcolm at gcc dot gnu.org
2022-06-13 20:36 ` eggert at cs dot ucla.edu
2022-06-13 20:47 ` dmalcolm at gcc dot gnu.org
2022-06-13 22:16 ` dmalcolm at gcc dot gnu.org
2024-02-16 14:13 ` dmalcolm 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).