Skip to content

Commit 12791a1

Browse files
nmischhs-liuxh
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
1 parent 70d65bc commit 12791a1

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
@@ -975,14 +975,14 @@ text_substring(Datum str, int32 start, int32 length, bool length_not_specified)
975975

976976
if (length_not_specified) /* special case - get length to end of
977977
* string */
978-
slice_size = L1 = -1;
978+
E = slice_size = L1 = -1;
979979
else if (length < 0)
980980
{
981981
/* SQL99 says to throw an error for E < S, i.e., negative length */
982982
ereport(ERROR,
983983
(errcode(ERRCODE_SUBSTRING_ERROR),
984984
errmsg("negative substring length not allowed")));
985-
slice_size = L1 = -1; /* silence stupider compilers */
985+
E = slice_size = L1 = -1; /* silence stupider compilers */
986986
}
987987
else if (pg_add_s32_overflow(S, length, &E))
988988
{

0 commit comments

Comments
 (0)