https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77425
Bug ID: 77425
Summary: Pointer test follows dereference in sched-int.h
Product: gcc
Version: 7.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: rtl-optimization
Assignee: unassigned at gcc dot gnu.org
Reporter: redi at gcc dot gnu.org
Blocks: 77421
Target Milestone: ---
sd_iterator_cond in gcc/sched-int.h has:
it_ptr->linkp = &DEPS_LIST_FIRST (list);
if (list)
continue;
where DEPS_LIST_FIRST dereferences list, so either the test is always true or
the dereference is undefined behavious.
Maybe it should be:
it_ptr->linkp = list ? &DEPS_LIST_FIRST (list) : NULL;
if (list)
continue;
Referenced Bugs:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77421
[Bug 77421] Bugs found in GCC with the help of PVS-Studio