Hi!
While playing with some unrelated to the topic stuff, I've noticed a strange warning from verify_heapam.c:730:25:
warning: ‘xmax_status’ may be used uninitialized in this function.
This happens only when get_xid_status is inlined, and only in GCC with O3. I use a GCC version 11.3.0.
For the purpose of investigation, I've created a PFA patch to force get_xid_status inline.
$ CFLAGS="-O3" ./configure -q && make -s -j12 >/dev/null && make -s -j12 -C contrib
verify_heapam.c: In function ‘check_tuple_visibility’:
verify_heapam.c:730:25: warning: ‘xmax_status’ may be used uninitialized in this function [-Wmaybe-uninitialized]
730 | XidCommitStatus xmax_status;
| ^~~~~~~~~~~
verify_heapam.c:909:25: warning: ‘xmin_status’ may be used uninitialized in this function [-Wmaybe-uninitialized]
909 | else if (xmin_status != XID_COMMITTED)
|
I believe, this warning is false positive, since mentioned row is unreachable. If xid is invalid, we return from get_xid_status
XID_INVALID and could not pass
770 ········if (HeapTupleHeaderXminInvalid(tuphdr))
771 ············return false;·······/* inserter aborted, don't check */
So, I think this warning is false positive. On the other hand, we could simply init status variable in get_xid_status and
make this code more errors/warnings safe. Thoughts?
--
Best regards,
Maxim Orlov.