Bug 89202 - missing -Wnonnull-dereference or -Wuninitialized for a certain bug (CCP)
Summary: missing -Wnonnull-dereference or -Wuninitialized for a certain bug (CCP)
Status: RESOLVED DUPLICATE of bug 18501
Alias: None
Product: gcc
Classification: Unclassified
Component: tree-optimization (show other bugs)
Version: 9.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
Keywords: diagnostic
Depends on:
Blocks: Wuninitialized Wnull-dereference
  Show dependency treegraph
Reported: 2019-02-05 04:09 UTC by Martin Sebor
Modified: 2021-04-15 23:05 UTC (History)
2 users (show)

See Also:
Known to work:
Known to fail:
Last reconfirmed: 2019-11-02 00:00:00


Note You need to log in before you can comment on or make changes to this bug.
Description Martin Sebor 2019-02-05 04:09:36 UTC
The following function either reads a variable that has not been initialized or dererefernces a null pointer, but can never be executed without an error.  Yet GCC issues neither -Wuninitialized/-Wmaybe-uninitialized nor -Wnull-dereference.

$ cat z.c && gcc -O2 -S -Wall -Wextra -Wnull-dereference -fdump-tree-optimized=/dev/stdout z.c
void f (int *s)
  int i;

  if (!s)
    i = 0;

  *s = i;

;; Function f (f, funcdef_no=0, decl_uid=1906, cgraph_uid=1, symbol_order=0)

f (int * s)
  <bb 2> [local count: 1073741824]:
  *s_1(D) = 0;

Comment 1 Manuel López-Ibáñez 2019-11-02 15:17:40 UTC
For the Wuninit, this is PR18501
Comment 2 Martin Sebor 2021-04-15 23:05:39 UTC
Agreed, it's dupe of pr18501.  -Wnull-dereference would benefit from the same predicate analysis as -Wmaybe-uninitialized.

*** This bug has been marked as a duplicate of bug 18501 ***