From 3553e1d1f037df79b10e5f8589884c02e57fe144 Mon Sep 17 00:00:00 2001 From: Gary Houston Date: Tue, 24 Sep 2002 22:21:01 +0000 Subject: * inline.h (scm_double_cell): prevent reordering of statements with any following code (for GCC 3 strict-aliasing). * numbers.c (scm_make_real), num2float.i.c (FLOAT2NUM): removed the earlier version of the reordering prevention. --- libguile/inline.h | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'libguile/inline.h') diff --git a/libguile/inline.h b/libguile/inline.h index d4cd67606..393182b6a 100644 --- a/libguile/inline.h +++ b/libguile/inline.h @@ -213,6 +213,26 @@ scm_double_cell (scm_t_bits car, scm_t_bits cbr, /* see above. */ SCM_SET_GC_MARK (z); +#endif + + /* When this function is inlined, it's possible that the last + SCM_GC_SET_CELL_WORD above will be adjacent to a following + initialization of z. E.g., it occurred in scm_make_real. GCC + from around version 3 (e.g., certainly 3.2) began taking + advantage of strict C aliasing rules which say that it's OK to + interchange the initialization above and the one below when the + pointer types appear to differ sufficiently. We don't want that, + of course. GCC allows this behaviour to be disabled with the + -fno-strict-aliasing option, but would also need to be supplied + by Guile users. Instead, the following statements prevent the + reordering. + */ +#ifdef __GNUC__ + asm volatile ("" : : : "memory"); +#else + /* portable version, just in case any other compiler does the same + thing. */ + scm_remember_upto_here_1 (z); #endif return z; -- cgit v1.2.3