ruby-changes:49313
From: naruse <ko1@a...>
Date: Sun, 24 Dec 2017 01:18:16 +0900 (JST)
Subject: [ruby-changes:49313] naruse:r61429 (trunk): undef HAVE_BUILTIN___BUILTIN_CHOOSE_EXPR_CONSTANT_P on GCC 4.8
naruse 2017-12-24 01:17:57 +0900 (Sun, 24 Dec 2017) New Revision: 61429 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=61429 Log: undef HAVE_BUILTIN___BUILTIN_CHOOSE_EXPR_CONSTANT_P on GCC 4.8 GCC 4.8 with optimization causes error if it compiles following code. [Bug #14221] ```c __builtin_choose_expr(__builtin_constant_p(b),0,1) ``` https://github.com/ruby/ruby/pull/1778 Modified files: trunk/include/ruby/defines.h trunk/include/ruby/ruby.h Index: include/ruby/ruby.h =================================================================== --- include/ruby/ruby.h (revision 61428) +++ include/ruby/ruby.h (revision 61429) @@ -26,15 +26,17 @@ extern "C" { https://github.com/ruby/ruby/blob/trunk/include/ruby/ruby.h#L26 #include RUBY_EXTCONF_H #endif +#include "defines.h" + #if defined(__cplusplus) /* __builtin_choose_expr and __builtin_types_compatible aren't available * on C++. See https://gcc.gnu.org/onlinedocs/gcc/Other-Builtins.html */ # undef HAVE_BUILTIN___BUILTIN_CHOOSE_EXPR_CONSTANT_P # undef HAVE_BUILTIN___BUILTIN_TYPES_COMPATIBLE_P +#elif GCC_VERSION_BEFORE(4,8,6) /* Bug #14221 */ +# undef HAVE_BUILTIN___BUILTIN_CHOOSE_EXPR_CONSTANT_P #endif -#include "defines.h" - #ifndef ASSUME # ifdef UNREACHABLE # define ASSUME(x) (RB_LIKELY(!!(x)) ? (void)0 : UNREACHABLE) Index: include/ruby/defines.h =================================================================== --- include/ruby/defines.h (revision 61428) +++ include/ruby/defines.h (revision 61429) @@ -72,6 +72,17 @@ extern "C" { https://github.com/ruby/ruby/blob/trunk/include/ruby/defines.h#L72 # define GCC_VERSION_SINCE(major, minor, patchlevel) 0 # endif #endif +#ifndef GCC_VERSION_BEFORE +# if defined(__GNUC__) && !defined(__INTEL_COMPILER) && !defined(__clang__) +# define GCC_VERSION_BEFORE(major, minor, patchlevel) \ + ((__GNUC__ < (major)) || \ + ((__GNUC__ == (major) && \ + ((__GNUC_MINOR__ < (minor)) || \ + (__GNUC_MINOR__ == (minor) && __GNUC_PATCHLEVEL__ <= (patchlevel)))))) +# else +# define GCC_VERSION_BEFORE(major, minor, patchlevel) 0 +# endif +#endif /* likely */ #if __GNUC__ >= 3 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/