From fd12bc1896bd4a78b9ff376fd685a009254b153f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8D=9C=E9=83=A8=E6=98=8C=E5=B9=B3?= Date: Thu, 9 Sep 2021 12:20:40 +0900 Subject: [PATCH] ruby_scan_oct, ruby_scan_hex: are not pure Silly bug, they write back consumed bytes through passed pointers. Must never be pure functions. ruby_scan_oct does not refer any static variables so it can still be __declspec(noalias), while ruby_scan_hex is not because it reads from ruby_digit36_to_number_table. --- include/ruby/util.h | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/include/ruby/util.h b/include/ruby/util.h index dfe215eed7..b2bc1a09f6 100644 --- a/include/ruby/util.h +++ b/include/ruby/util.h @@ -23,12 +23,11 @@ # include /* ssize_t */ #endif +#include "ruby/internal/attr/noalias.h" #include "ruby/internal/attr/nodiscard.h" #include "ruby/internal/attr/nonnull.h" -#include "ruby/internal/attr/pure.h" #include "ruby/internal/attr/restrict.h" #include "ruby/internal/attr/returns_nonnull.h" -#include "ruby/internal/config.h" #include "ruby/internal/dllexport.h" #include "ruby/defines.h" @@ -74,7 +73,7 @@ unsigned long ruby_scan_digits(const char *str, ssize_t len, int base, size_t *r /** @old{ruby_scan_oct} */ #define scan_oct(s,l,e) ((int)ruby_scan_oct((s),(l),(e))) -RBIMPL_ATTR_PURE() +RBIMPL_ATTR_NOALIAS() RBIMPL_ATTR_NONNULL(()) /** * Interprets the passed string as an octal unsigned integer. Stops when @@ -97,7 +96,6 @@ unsigned long ruby_scan_oct(const char *str, size_t len, size_t *consumed); /** @old{ruby_scan_hex} */ #define scan_hex(s,l,e) ((int)ruby_scan_hex((s),(l),(e))) -RBIMPL_ATTR_PURE() RBIMPL_ATTR_NONNULL(()) /** * Interprets the passed string a hexadecimal unsigned integer. Stops when