public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug analyzer/94447] New: Not handling CONSTRUCTOR tree code
@ 2020-04-01 16:10 dmalcolm at gcc dot gnu.org
  2020-04-28 13:26 ` [Bug analyzer/94447] " cvs-commit at gcc dot gnu.org
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: dmalcolm at gcc dot gnu.org @ 2020-04-01 16:10 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 94447
           Summary: Not handling CONSTRUCTOR tree code
           Product: gcc
           Version: 10.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: ---

Consider e.g.:

struct foo
{
  int *v;
};

int test (void)
{
  struct foo f = {};
  return *f.v;
}

This currently reports
t.c: In function ‘test’:
t.c:9:10: warning: use of uninitialized value ‘<unknown>’ [CWE-457]
[-Wanalyzer-use-of-uninitialized-value]
    9 |   return *f.v;
      |          ^~~~
  ‘test’: event 1
    |
    |

when it should be a NULL dereference.

The f = {}; shows up as f = {}; in the gimple dump, a CONSTRUCTOR, and
region_model::on_assignment is hitting a TODO for that tree code.

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

* [Bug analyzer/94447] Not handling CONSTRUCTOR tree code
  2020-04-01 16:10 [Bug analyzer/94447] New: Not handling CONSTRUCTOR tree code dmalcolm at gcc dot gnu.org
@ 2020-04-28 13:26 ` cvs-commit at gcc dot gnu.org
  2020-04-28 13:36 ` dmalcolm at gcc dot gnu.org
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2020-04-28 13:26 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by David Malcolm <dmalcolm@gcc.gnu.org>:

https://gcc.gnu.org/g:78b9783774bfd3540f38f5b1e3c7fc9f719653d7

commit r10-8012-g78b9783774bfd3540f38f5b1e3c7fc9f719653d7
Author: David Malcolm <dmalcolm@redhat.com>
Date:   Thu Apr 23 21:31:22 2020 -0400

    analyzer: remove -Wanalyzer-use-of-uninitialized-value for GCC 10

    From what I can tell -Wanalyzer-use-of-uninitialized-value has not
    yet found a true diagnostic in real-world code, and seems to be
    particularly susceptible to false positives.  These relate to bugs in
    the region_model code.

    For GCC 10 it seems best to remove this warning, which this patch does.
    Internally it also removes POISON_KIND_UNINIT.

    I'm working on a rewrite of the region_model code for GCC 11 that I
    hope will fix these issues, and allow this warning to be reintroduced.

    gcc/analyzer/ChangeLog:
            PR analyzer/94447
            PR analyzer/94639
            PR analyzer/94732
            PR analyzer/94754
            * analyzer.opt (Wanalyzer-use-of-uninitialized-value): Delete.
            * program-state.cc (selftest::test_program_state_dumping): Update
            expected dump result for removal of "uninit".
            * region-model.cc (poison_kind_to_str): Delete POISON_KIND_UNINIT
            case.
            (root_region::ensure_stack_region): Initialize stack with null
            svalue_id rather than with a typeless POISON_KIND_UNINIT value.
            (root_region::ensure_heap_region): Likewise for the heap.
            (region_model::dump_summary_of_rep_path_vars): Remove
            summarization of uninit values.
            (region_model::validate): Remove check that the stack has a
            POISON_KIND_UNINIT value.
            (poisoned_value_diagnostic::emit): Remove POISON_KIND_UNINIT
            case.
            (poisoned_value_diagnostic::describe_final_event): Likewise.
            (selftest::test_dump): Update expected dump result for removal of
            "uninit".
            (selftest::test_svalue_equality): Remove "uninit" and "freed".
            * region-model.h (enum poison_kind): Remove POISON_KIND_UNINIT.

    gcc/ChangeLog:
            PR analyzer/94447
            PR analyzer/94639
            PR analyzer/94732
            PR analyzer/94754
            * doc/invoke.texi (Static Analyzer Options): Remove
            -Wanalyzer-use-of-uninitialized-value.
            (-Wno-analyzer-use-of-uninitialized-value): Remove item.

    gcc/testsuite/ChangeLog:
            PR analyzer/94447
            PR analyzer/94639
            PR analyzer/94732
            PR analyzer/94754
            * gcc.dg/analyzer/data-model-1.c: Mark "use of uninitialized
            value" warnings as xfail for now.
            * gcc.dg/analyzer/data-model-5b.c: Remove uninitialized warning.
            * gcc.dg/analyzer/pr94099.c: Mark "uninitialized" warning as xfail
            for now.
            * gcc.dg/analyzer/pr94447.c: New test.
            * gcc.dg/analyzer/pr94639.c: New test.
            * gcc.dg/analyzer/pr94732.c: New test.
            * gcc.dg/analyzer/pr94754.c: New test.
            * gcc.dg/analyzer/zlib-6.c: Mark "uninitialized" warning as xfail
            for now.

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

* [Bug analyzer/94447] Not handling CONSTRUCTOR tree code
  2020-04-01 16:10 [Bug analyzer/94447] New: Not handling CONSTRUCTOR tree code dmalcolm at gcc dot gnu.org
  2020-04-28 13:26 ` [Bug analyzer/94447] " cvs-commit at gcc dot gnu.org
@ 2020-04-28 13:36 ` dmalcolm at gcc dot gnu.org
  2020-05-08 13:14 ` dmalcolm at gcc dot gnu.org
  2020-08-18  0:59 ` dmalcolm at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: dmalcolm at gcc dot gnu.org @ 2020-04-28 13:36 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from David Malcolm <dmalcolm at gcc dot gnu.org> ---
r10-8012-g78b9783774bfd3540f38f5b1e3c7fc9f719653d7 removes the false positive,
but we should still handle CONSTRUCTOR tree nodes.  Keeping this open.

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

* [Bug analyzer/94447] Not handling CONSTRUCTOR tree code
  2020-04-01 16:10 [Bug analyzer/94447] New: Not handling CONSTRUCTOR tree code dmalcolm at gcc dot gnu.org
  2020-04-28 13:26 ` [Bug analyzer/94447] " cvs-commit at gcc dot gnu.org
  2020-04-28 13:36 ` dmalcolm at gcc dot gnu.org
@ 2020-05-08 13:14 ` dmalcolm at gcc dot gnu.org
  2020-08-18  0:59 ` dmalcolm at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: dmalcolm at gcc dot gnu.org @ 2020-05-08 13:14 UTC (permalink / raw)
  To: gcc-bugs

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

David Malcolm <dmalcolm at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |tommy-gccbugs at thorn dot ws

--- Comment #3 from David Malcolm <dmalcolm at gcc dot gnu.org> ---
*** Bug 94999 has been marked as a duplicate of this bug. ***

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

* [Bug analyzer/94447] Not handling CONSTRUCTOR tree code
  2020-04-01 16:10 [Bug analyzer/94447] New: Not handling CONSTRUCTOR tree code dmalcolm at gcc dot gnu.org
                   ` (2 preceding siblings ...)
  2020-05-08 13:14 ` dmalcolm at gcc dot gnu.org
@ 2020-08-18  0:59 ` dmalcolm at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: dmalcolm at gcc dot gnu.org @ 2020-08-18  0:59 UTC (permalink / raw)
  To: gcc-bugs

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

David Malcolm <dmalcolm at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |FIXED
             Status|UNCONFIRMED                 |RESOLVED

--- Comment #4 from David Malcolm <dmalcolm at gcc dot gnu.org> ---
I implemented gassign from CONSTRUCTOR in
r11-2694-g808f4dfeb3a95f50f15e71148e5c1067f90a126d, including a test case for
the example in comment #0.  Marking this one as resolved.

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

end of thread, other threads:[~2020-08-18  0:59 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-01 16:10 [Bug analyzer/94447] New: Not handling CONSTRUCTOR tree code dmalcolm at gcc dot gnu.org
2020-04-28 13:26 ` [Bug analyzer/94447] " cvs-commit at gcc dot gnu.org
2020-04-28 13:36 ` dmalcolm at gcc dot gnu.org
2020-05-08 13:14 ` dmalcolm at gcc dot gnu.org
2020-08-18  0:59 ` 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).