Skip to content

Commit 11b91fa

Browse files
author
Artur Zakirov
committed
Fix the tmpsml optimization by gcc
1 parent cdfb1bd commit 11b91fa

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

contrib/pg_trgm/trgm_gist.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,12 @@ gtrgm_consistent(PG_FUNCTION_ARGS)
296296

297297
if (GIST_LEAF(entry))
298298
{ /* all leafs contains orig trgm */
299-
float4 tmpsml = cnt_sml(qtrg, key, *recheck);
299+
/*
300+
* Prevent gcc optimizing the tmpsml variable using volatile
301+
* keyword. Otherwise comparison of nlimit and tmpsml may give
302+
* wrong results.
303+
*/
304+
float4 volatile tmpsml = cnt_sml(qtrg, key, *recheck);
300305

301306
/* strange bug at freebsd 5.2.1 and gcc 3.3.3 */
302307
res = (*(int *) &tmpsml == *(int *) &nlimit || tmpsml > nlimit);

0 commit comments

Comments
 (0)