public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug analyzer/109014] New: -Wanalyzer-use-of-uninitialized-value seen in pcre2-10.42's pcre2test.c
@ 2023-03-03 18:24 dmalcolm at gcc dot gnu.org
  2023-03-03 18:29 ` [Bug analyzer/109014] " dmalcolm at gcc dot gnu.org
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: dmalcolm at gcc dot gnu.org @ 2023-03-03 18:24 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 109014
           Summary: -Wanalyzer-use-of-uninitialized-value seen in
                    pcre2-10.42's pcre2test.c
           Product: gcc
           Version: 13.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: analyzer
          Assignee: dmalcolm at gcc dot gnu.org
          Reporter: dmalcolm at gcc dot gnu.org
  Target Milestone: ---

Created attachment 54579
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=54579&action=edit
Partially reducer reproducer

I'm about to commit a patch that provides a prototype implementation of
sprintf; this leads to a new false positive on the attached:


pcre2test.c: In function 'format_list_item':
pcre2test.c:4448:21: warning: use of uninitialized value '*ff_44(D) + _2'
[CWE-457] [-Wanalyzer-use-of-uninitialized-value]
 4448 |   for (count = 0; ff[count] >= 0; count++) {
      |                   ~~^~~~~~~
  'main': events 1-12
    |
    | 4565 | main(int argc, char** argv)
    |      | ^~~~
    |      | |
    |      | (1) entry to 'main'
    |......
    | 4579 |   while (argc > 1 && argv[op][0] == '-' && argv[op][1] != 0) {
    |      |          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    |      |                                         |
    |      |                                         (2) following 'true'
branch...
    |      |                                         (8) following 'true'
branch...
    | 4580 |     /* [...snip...] */
    | 4581 |     char* arg = argv[op];
    |      |                     ~
    |      |                     |
    |      |                     (3) ...to here
    |      |                     (9) ...to here
    |......
    | 4585 |     if (strcmp(arg, "-LP") == 0) {
    |      |        ~
    |      |        |
    |      |        (4) following 'false' branch (when the strings are
non-equal)...
    |      |        (10) following 'true' branch (when the strings are
equal)...
    | 4586 |       display_properties(0);
    |      |       ~~~~~~~~~~~~~~~~~~~~~
    |      |       |
    |      |       (11) ...to here
    |      |       (12) calling 'display_properties' from 'main'
    |......
    | 4592 |     if (strcmp(arg, "-8") == 0) {
    |      |        ~~~~~~~~~~~~~~~~~~
    |      |        ||
    |      |        |(5) ...to here
    |      |        (6) following 'true' branch (when the strings are equal)...
    | 4593 |       test_mode = 8;
    |      |       ~~~~~~~~~~~~~
    |      |                 |
    |      |                 (7) ...to here
    |
    +--> 'display_properties': events 13-25
           |
           | 4481 | display_properties(BOOL wantscripts)
           |      | ^~~~~~~~~~~~~~~~~~
           |      | |
           |      | (13) entry to 'display_properties'
           |......
           | 4487 |   int16_t found[256][5 + 1];
           |      |           ~~~~~
           |      |           |
           |      |           (14) region created on stack here
           |......
           | 4492 |   if (wantscripts) {
           |      |      ~
           |      |      |
           |      |      (15) following 'false' branch (when 'wantscripts ==
0')...
           |......
           | 4496 |     n = ucp_Bprop_Count;
           |      |     ~~~~~~~~~~~~~~~~~~~
           |      |       |
           |      |       (16) ...to here
           |......
           | 4500 |   for (size_t i = 0; i < utt_size; i++) {
           |      |                      ~~~~~~~~~~~~
           |      |                        |
           |      |                        (17) following 'true' branch...
           | 4501 |     int k;
           | 4502 |     int m = 0;
           |      |         ~
           |      |         |
           |      |         (18) ...to here
           |......
           | 4507 |     if (wantscripts) {
           |      |        ~
           |      |        |
           |      |        (19) following 'false' branch (when 'wantscripts ==
0')...
           |......
           | 4511 |       if (t->type != 13)
           |      |          ~~~~~~~~
           |      |          | |
           |      |          | (20) ...to here
           |      |          (21) following 'true' branch...
           |      |          (22) ...to here
           |......
           | 4544 |   for (int k = 0; k < (n + 1) / 2; k++) {
           |      |                   ~~~~~~~~~~~~~~~
           |      |                     |
           |      |                     (23) following 'true' branch...
           |......
           | 4549 |     format_list_item(found[k], buff1, wantscripts);
           |      |     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
           |      |     |                     |
           |      |     |                     (24) ...to here
           |      |     (25) calling 'format_list_item' from
'display_properties'
           |
           +--> 'format_list_item': events 26-27
                  |
                  | 4441 | format_list_item(int16_t* ff, char* buff, BOOL
isscript)
                  |      | ^~~~~~~~~~~~~~~~
                  |      | |
                  |      | (26) entry to 'format_list_item'
                  |......
                  | 4448 |   for (count = 0; ff[count] >= 0; count++) {
                  |      |                   ~~~~~~~~~
                  |      |                     |
                  |      |                     (27) use of uninitialized value
'*ff_44(D) + _2' here
                  |

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

end of thread, other threads:[~2024-05-21  9:14 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-03 18:24 [Bug analyzer/109014] New: -Wanalyzer-use-of-uninitialized-value seen in pcre2-10.42's pcre2test.c dmalcolm at gcc dot gnu.org
2023-03-03 18:29 ` [Bug analyzer/109014] " dmalcolm at gcc dot gnu.org
2023-03-03 23:01 ` cvs-commit at gcc dot gnu.org
2024-03-04 13:00 ` [Bug analyzer/109014] [13/14 Regression] " rguenth at gcc dot gnu.org
2024-03-08 15:38 ` law at gcc dot gnu.org
2024-05-21  9:14 ` [Bug analyzer/109014] [13/14/15 " jakub 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).