Re: gcc 15 "array subscript 0" warning at level -O3

Andres Freund <andres@anarazel.de>

From: Andres Freund <andres@anarazel.de>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: pgsql-hackers@lists.postgresql.org
Date: 2025-07-09T23:20:20Z
Lists: pgsql-hackers
Hi,

On 2025-06-05 15:50:48 -0400, Tom Lane wrote:
> Andres Freund <andres@anarazel.de> writes:
> >> I've been wondering about adding wrapping something like that in a
> >> pg_assume(expr) or such.
> 
> > I've been once more annoyed by this warning. Here's a prototype for the
> > approach outlined above.
> 
> Looks plausible by eyeball.  I did notice a typo in the comment:
> 
> + * pg_assume(expr) stats that we assume `expr` to evaluate to true. In assert
> 
> s/stats/states/, I think you meant.

Thanks.  I pushed it with that tweak and a bit of minor comment burnishing.
Glad to see the last of that warning.

Greetings,

Andres Freund



Commits

  1. Use pg_assume() to avoid compiler warning below exec_set_found()

  2. Add pg_assume(expr) macro