8000 Use pg_assume() to avoid compiler warning below exec_set_found() · postgres/postgres@48a23f6 · GitHub
[go: up one dir, main page]

Skip to content
8000

Commit 48a23f6

Browse files
committed
Use pg_assume() to avoid compiler warning below exec_set_found()
The warning, visible when building with -O3 and a recent-ish gcc, is due to gcc not realizing that found is a byvalue type and therefore will never be interpreted as a varlena type. Discussion: https://postgr.es/m/3prdb6hkep3duglhsujrn52bkvnlkvhc54fzvph2emrsm4vodl@77yy6j4hkemb Discussion: https://postgr.es/m/20230316172818.x6375uvheom3ibt2%40awork3.anarazel.de Discussion: https://postgr.es/m/20240207203138.sknifhlppdtgtxnk%40awork3.anarazel.de
1 parent d65eb5b commit 48a23f6

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/pl/plpgsql/src/pl_exec.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8610,6 +8610,15 @@ exec_set_found(PLpgSQL_execstate *estate, bool state)
86108610
PLpgSQL_var *var;
86118611

86128612
var = (PLpgSQL_var *) (estate->datums[estate->found_varno]);
8613+
8614+
/*
8615+
* Use pg_assume() to avoid a spurious warning with some compilers, by
8616+
* telling the compiler that the VARATT_IS_EXTERNAL_NON_EXPANDED() branch
8617+
* in assign_simple_var() will never be reached when called from here, due
8618+
* to "found" being a boolean (i.e. a byvalue type), not a varlena.
8619+
*/
8620+
pg_assume(var->datatype->typlen != -1);
8621+
86138622
assign_simple_var(estate, var, BoolGetDatum(state), false, false);
86148623
}
86158624

0 commit comments

Comments
 (0)
0