public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug analyzer/110529] New: -Wanalyzer-null-dereference false nagetive with `*arr[0] = 10086`
@ 2023-07-03  7:26 dale.mengli.ming at proton dot me
  2023-07-03  7:35 ` [Bug analyzer/110529] " dale.mengli.ming at proton dot me
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: dale.mengli.ming at proton dot me @ 2023-07-03  7:26 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 110529
           Summary: -Wanalyzer-null-dereference false nagetive with
                    `*arr[0] = 10086`
           Product: gcc
           Version: 14.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: analyzer
          Assignee: dmalcolm at gcc dot gnu.org
          Reporter: dale.mengli.ming at proton dot me
  Target Milestone: ---

Hi,

```c
void foo(int pc) {
    int *arr[2] = {&&x, &&y};
    int var = 0;
    goto *arr[pc];

x:
    arr[0] = (void *)0;
    *arr[0] = 10086;
    return;
y:
    return;
}

int main() { foo(0); }
```

in this case, the analyzer with `-O3` doesn't report an NPD about `*arr[0] =
10086`.

See it live: https://godbolt.org/z/1E9e5oKdE.

Thanks for taking the time to review this case.

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

* [Bug analyzer/110529] -Wanalyzer-null-dereference false nagetive with `*arr[0] = 10086`
  2023-07-03  7:26 [Bug analyzer/110529] New: -Wanalyzer-null-dereference false nagetive with `*arr[0] = 10086` dale.mengli.ming at proton dot me
@ 2023-07-03  7:35 ` dale.mengli.ming at proton dot me
  2023-08-22  2:59 ` dale.mengli.ming at proton dot me
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: dale.mengli.ming at proton dot me @ 2023-07-03  7:35 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from mengli ming <dale.mengli.ming at proton dot me> ---
It's a little odd that there is no output (https://godbolt.org/z/GhshzvaTq) for
`_analyzer_eval(1)` in line 9 and line 13.

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

* [Bug analyzer/110529] -Wanalyzer-null-dereference false nagetive with `*arr[0] = 10086`
  2023-07-03  7:26 [Bug analyzer/110529] New: -Wanalyzer-null-dereference false nagetive with `*arr[0] = 10086` dale.mengli.ming at proton dot me
  2023-07-03  7:35 ` [Bug analyzer/110529] " dale.mengli.ming at proton dot me
@ 2023-08-22  2:59 ` dale.mengli.ming at proton dot me
  2023-09-02 14:24 ` [Bug analyzer/110529] Analyzer fails to handle computed goto dmalcolm at gcc dot gnu.org
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: dale.mengli.ming at proton dot me @ 2023-08-22  2:59 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from mengli ming <dale.mengli.ming at proton dot me> ---
Um, would you be available to take a look at this case? Your insights would be
greatly appreciated!

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

* [Bug analyzer/110529] Analyzer fails to handle computed goto
  2023-07-03  7:26 [Bug analyzer/110529] New: -Wanalyzer-null-dereference false nagetive with `*arr[0] = 10086` dale.mengli.ming at proton dot me
  2023-07-03  7:35 ` [Bug analyzer/110529] " dale.mengli.ming at proton dot me
  2023-08-22  2:59 ` dale.mengli.ming at proton dot me
@ 2023-09-02 14:24 ` dmalcolm at gcc dot gnu.org
  2023-09-07 22:45 ` cvs-commit at gcc dot gnu.org
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: dmalcolm at gcc dot gnu.org @ 2023-09-02 14:24 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
            Summary|-Wanalyzer-null-dereference |Analyzer fails to handle
                   |false nagetive with         |computed goto
                   |`*arr[0] = 10086`           |
     Ever confirmed|0                           |1
   Last reconfirmed|                            |2023-09-02

--- Comment #3 from David Malcolm <dmalcolm at gcc dot gnu.org> ---
Thanks for filing this bug.

Looking at
  -fdump-analyzer-exploded-graph -fanalyzer-fine-grained
it looks like the analyzer gives up exploring execution paths at the computed
goto.

The supergraph shows that the CFG at the goto has out-edges to x and y, with
the flag "ABNORMAL".

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

* [Bug analyzer/110529] Analyzer fails to handle computed goto
  2023-07-03  7:26 [Bug analyzer/110529] New: -Wanalyzer-null-dereference false nagetive with `*arr[0] = 10086` dale.mengli.ming at proton dot me
                   ` (2 preceding siblings ...)
  2023-09-02 14:24 ` [Bug analyzer/110529] Analyzer fails to handle computed goto dmalcolm at gcc dot gnu.org
@ 2023-09-07 22:45 ` cvs-commit at gcc dot gnu.org
  2023-09-07 22:58 ` dmalcolm at gcc dot gnu.org
  2023-09-17  4:05 ` dale.mengli.ming at proton dot me
  5 siblings, 0 replies; 7+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-09-07 22:45 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 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:1b761fede44afac5fa72e77caced9beda93fb381

commit r14-3796-g1b761fede44afac5fa72e77caced9beda93fb381
Author: David Malcolm <dmalcolm@redhat.com>
Date:   Thu Sep 7 18:43:05 2023 -0400

    analyzer: basic support for computed gotos (PR analyzer/110529)

    PR analyzer/110529 notes that -fanalyzer was giving up on execution
    paths that follow a computed goto, due to ignoring CFG edges with the
    flag EDGE_ABNORMAL set.

    This patch implements enough handling for them to allow analysis of
    such execution paths to continue.

    gcc/analyzer/ChangeLog:
            PR analyzer/110529
            * program-point.cc (program_point::on_edge): Don't reject
            EDGE_ABNORMAL for computed gotos.
            * region-model.cc (region_model::maybe_update_for_edge): Handle
            computed goto statements.
            (region_model::apply_constraints_for_ggoto): New.
            * region-model.h (region_model::apply_constraints_for_ggoto): New
decl.
            * supergraph.cc (supernode::get_label): New.
            * supergraph.h (supernode::get_label): New decl.

    gcc/testsuite/ChangeLog:
            PR analyzer/110529
            * c-c++-common/analyzer/computed-goto-1.c: New test.
            * gcc.dg/analyzer/computed-goto-pr110529.c: New test.

    Signed-off-by: David Malcolm <dmalcolm@redhat.com>

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

* [Bug analyzer/110529] Analyzer fails to handle computed goto
  2023-07-03  7:26 [Bug analyzer/110529] New: -Wanalyzer-null-dereference false nagetive with `*arr[0] = 10086` dale.mengli.ming at proton dot me
                   ` (3 preceding siblings ...)
  2023-09-07 22:45 ` cvs-commit at gcc dot gnu.org
@ 2023-09-07 22:58 ` dmalcolm at gcc dot gnu.org
  2023-09-17  4:05 ` dale.mengli.ming at proton dot me
  5 siblings, 0 replies; 7+ messages in thread
From: dmalcolm at gcc dot gnu.org @ 2023-09-07 22:58 UTC (permalink / raw)
  To: gcc-bugs

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

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

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

--- Comment #5 from David Malcolm <dmalcolm at gcc dot gnu.org> ---
Should be fixed on trunk for gcc 14 by the above commit.

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

* [Bug analyzer/110529] Analyzer fails to handle computed goto
  2023-07-03  7:26 [Bug analyzer/110529] New: -Wanalyzer-null-dereference false nagetive with `*arr[0] = 10086` dale.mengli.ming at proton dot me
                   ` (4 preceding siblings ...)
  2023-09-07 22:58 ` dmalcolm at gcc dot gnu.org
@ 2023-09-17  4:05 ` dale.mengli.ming at proton dot me
  5 siblings, 0 replies; 7+ messages in thread
From: dale.mengli.ming at proton dot me @ 2023-09-17  4:05 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #6 from mengli ming <dale.mengli.ming at proton dot me> ---
(In reply to David Malcolm from comment #5)
> Should be fixed on trunk for gcc 14 by the above commit.

Thanks a lot for your hard work!

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

end of thread, other threads:[~2023-09-17  4:05 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-07-03  7:26 [Bug analyzer/110529] New: -Wanalyzer-null-dereference false nagetive with `*arr[0] = 10086` dale.mengli.ming at proton dot me
2023-07-03  7:35 ` [Bug analyzer/110529] " dale.mengli.ming at proton dot me
2023-08-22  2:59 ` dale.mengli.ming at proton dot me
2023-09-02 14:24 ` [Bug analyzer/110529] Analyzer fails to handle computed goto dmalcolm at gcc dot gnu.org
2023-09-07 22:45 ` cvs-commit at gcc dot gnu.org
2023-09-07 22:58 ` dmalcolm at gcc dot gnu.org
2023-09-17  4:05 ` dale.mengli.ming at proton dot me

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