Skip to content

Commit 26a52c3

Browse files
nmischRucha Kulkarni
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 50d361f6223f8f560a7f6e36076ed333e9977a73)
1 parent d9d5143 commit 26a52c3

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

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

0 commit comments

Comments
 (0)