We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents 6a7ac5e + 7bc88be commit 392073cCopy full SHA for 392073c
contrib/pg_trgm/trgm_gist.c
@@ -296,7 +296,12 @@ gtrgm_consistent(PG_FUNCTION_ARGS)
296
297
if (GIST_LEAF(entry))
298
{ /* all leafs contains orig trgm */
299
- float4 tmpsml = cnt_sml(qtrg, key, *recheck);
+ /*
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);
305
306
/* strange bug at freebsd 5.2.1 and gcc 3.3.3 */
307
res = (*(int *) &tmpsml == *(int *) &nlimit || tmpsml > nlimit);
0 commit comments