ruby-changes:63088
From: =E5=8D=9C=E9=83=A8=E6=98=8C=E5=B9=B3 <ko1@a...>
Date: Fri, 25 Sep 2020 11:38:58 +0900 (JST)
Subject: [ruby-changes:63088] e75aed7abb (master): RBIMPL_ALIGNOF: do not use constexpr
https://git.ruby-lang.org/ruby.git/commit/?id=e75aed7abb From e75aed7abb7f869223ea05a2f96b2021b57bd98a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8D=9C=E9=83=A8=E6=98=8C=E5=B9=B3?= <shyouhei@r...> Date: Thu, 24 Sep 2020 10:58:01 +0900 Subject: RBIMPL_ALIGNOF: do not use constexpr Was definitely a bad idea to use constexpr. It is not ubiquitous. diff --git a/include/ruby/internal/stdalign.h b/include/ruby/internal/stdalign.h index 8d9a0d2..2bd8d94 100644 --- a/include/ruby/internal/stdalign.h +++ b/include/ruby/internal/stdalign.h @@ -26,14 +26,9 @@ https://github.com/ruby/ruby/blob/trunk/include/ruby/internal/stdalign.h#L26 # include <stddef.h> #endif -#include "ruby/internal/attr/artificial.h" -#include "ruby/internal/attr/const.h" -#include "ruby/internal/attr/constexpr.h" -#include "ruby/internal/attr/forceinline.h" #include "ruby/internal/compiler_is.h" #include "ruby/internal/has/attribute.h" #include "ruby/internal/has/declspec_attribute.h" -#include "ruby/internal/has/extension.h" #include "ruby/internal/has/feature.h" /** @@ -95,24 +90,21 @@ https://github.com/ruby/ruby/blob/trunk/include/ruby/internal/stdalign.h#L90 #elif defined(__cplusplus) # /* C++11 `alignof()` can be buggy. */ # /* see: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69560 */ -# /* But don't worry, we can use templates and `constexpr`. */ -# define RBIMPL_ALIGNOF(T) ruby::rbimpl_alignof<T>() +# /* But don't worry, we can use templates. */ +# define RBIMPL_ALIGNOF(T) (static_cast<size_t>(ruby::rbimpl_alignof<T>::value)) namespace ruby { template<typename T> -RBIMPL_ATTR_CONSTEXPR(CXX11) -RBIMPL_ATTR_ARTIFICIAL() -RBIMPL_ATTR_FORCEINLINE() -RBIMPL_ATTR_CONST() -static size_t -rbimpl_alignof() -{ +struct rbimpl_alignof { typedef struct { char _; T t; } type; - return offsetof(type, t); -} + + enum { + value = offsetof(type, t) + }; +}; } #elif RBIMPL_COMPILER_IS(MSVC) -- cgit v0.10.2 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/