Suppress -Warray-bounds warning in 9.2's xlog.c.
authorTom Lane <[email protected]>
Mon, 13 Dec 2021 16:57:11 +0000 (11:57 -0500)
committerTom Lane <[email protected]>
Mon, 13 Dec 2021 16:57:11 +0000 (11:57 -0500)
Late-model gcc delivers a confusing warning "'memcpy' offset [0, 63]
is out of the bounds [0, 0]" here, which turns out to be because it
thinks the "record" pointer might be NULL, which again is because
it doesn't know ereport(PANIC) won't return.  The least invasive
way to fix that is to insert a couple of abort() calls.  It's
surprising/fortunate that we don't have this issue in more places
... but this is the last remaining build warning with gcc 11.2.1,
so I'll settle for a narrow fix.

Discussion: https://postgr.es/m/d0316012-ece7-7b7e-2d36-9c38cb77cb3b@enterprisedb.com

src/backend/access/transam/xlog.c

index 5df79116f93f2885d5101a569e9eed799a473a67..c5d3631fcb1d1936fd8347ca68a6b0801ac475fd 100644 (file)
@@ -6601,6 +6601,7 @@ StartupXLOG(void)
             */
            ereport(PANIC,
                    (errmsg("could not locate a valid checkpoint record")));
+           abort();            /* NOTREACHED */
        }
        else
        {
@@ -6614,8 +6615,11 @@ StartupXLOG(void)
                InRecovery = true;      /* force recovery even if SHUTDOWNED */
            }
            else
+           {
                ereport(PANIC,
                     (errmsg("could not locate a valid checkpoint record")));
+               abort();        /* NOTREACHED */
+           }
        }
        memcpy(&checkPoint, XLogRecGetData(record), sizeof(CheckPoint));
        wasShutdown = (record->xl_info == XLOG_CHECKPOINT_SHUTDOWN);