Skip to content

Commit c65e452

Browse files
nmischtanscorpio7
authored andcommitted
Suppress new "may be used uninitialized" warning.
Various buildfarm members, having compilers like gcc 8.5 and 6.3, fail to deduce that text_substring() variable "E" is initialized if slice_size!=-1. This suppression approach quiets gcc 8.5; I did not reproduce the warning elsewhere. Back-patch to v14, like commit 9f4fd119b2cbb9a41ec0c19a8d6ec9b59b92c125. Reported-by: Tom Lane <tgl@sss.pgh.pa.us> Discussion: https://postgr.es/m/1157953.1771266105@sss.pgh.pa.us Backpatch-through: 14 (cherry picked from commit a0769e74d65dba80717255faf78b494692729d6b)
1 parent 894325a commit c65e452

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

src/backend/utils/adt/varlena.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -949,14 +949,14 @@ text_substring(Datum str, int32 start, int32 length, bool length_not_specified)
949949

950950
if (length_not_specified) /* special case - get length to end of
951951
* string */
952-
slice_size = L1 = -1;
952+
E = slice_size = L1 = -1;
953953
else if (length < 0)
954954
{
955955
/* SQL99 says to throw an error for E < S, i.e., negative length */
956956
ereport(ERROR,
957957
(errcode(ERRCODE_SUBSTRING_ERROR),
958958
errmsg("negative substring length not allowed")));
959-
slice_size = L1 = -1; /* silence stupider compilers */
959+
E = slice_size = L1 = -1; /* silence stupider compilers */
960960
}
961961
else if (pg_add_s32_overflow(S, length, &E))
962962
{

0 commit comments

Comments
 (0)