public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug analyzer/94713] New: Analyzer is buggy on uninitialized pointer
@ 2020-04-22 13:06 vincent-gcc at vinc17 dot net
  2020-04-23  5:13 ` [Bug analyzer/94713] " marxin at gcc dot gnu.org
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: vincent-gcc at vinc17 dot net @ 2020-04-22 13:06 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 94713
           Summary: Analyzer is buggy on uninitialized pointer
           Product: gcc
           Version: 10.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: analyzer
          Assignee: dmalcolm at gcc dot gnu.org
          Reporter: vincent-gcc at vinc17 dot net
  Target Milestone: ---

Test with: gcc-10 (Debian 10-20200418-1) 10.0.1 20200418 (experimental) [master
revision 27c171775ab:4c277008be0:c5bac7d127f288fd2f8a1f15c3f30da5903141c6]

Consider:

void f1 (int *);
void f2 (int);

int foo (void)
{
  int *p;

  f1 (p);
  f2 (p[0]);
  return 0;
}

zira% gcc-10 -Wall tst2.c -O3 -c -fanalyzer
tst2.c: In function ‘foo’:
tst2.c:8:3: warning: ‘p’ is used uninitialized in this function
[-Wuninitialize]
    8 |   f1 (p);
      |   ^~~~~~
tst2.c:9:3: warning: use of uninitialized value ‘p’ [CWE-457]
[-Wanalyzer-use-of-uninitialized-value]
    9 |   f2 (p[0]);
      |   ^~~~~~~~~
  ‘foo’: event 1
    |
    |

-Wuninitialize works as expected, but -Wanalyzer-use-of-uninitialized-value
outputs the warning message on p[0], though the ‘p’ in the warning message is
correct.

If I comment out the "f2 (p[0]);" line, I no longer get the warning from the
analyzer, which means that it is the p[0] that triggers the warning instead of
p.

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

end of thread, other threads:[~2021-07-15 19:35 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-22 13:06 [Bug analyzer/94713] New: Analyzer is buggy on uninitialized pointer vincent-gcc at vinc17 dot net
2020-04-23  5:13 ` [Bug analyzer/94713] " marxin at gcc dot gnu.org
2021-02-11 15:06 ` dimhen at gmail dot com
2021-02-12  8:37 ` vincent-gcc at vinc17 dot net
2021-07-15 19:09 ` cvs-commit at gcc dot gnu.org
2021-07-15 19:35 ` 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).