https://bugs.ruby-lang.org/https://bugs.ruby-lang.org/favicon.ico?17113305112019-07-27T09:22:41ZRuby Issue Tracking SystemRuby master - Misc #16025: 'st_check_for_sizeof_st_index_t' declared as array with a negative size (emscripten)https://bugs.ruby-lang.org/issues/16025?journal_id=801332019-07-27T09:22:41Znobu (Nobuyoshi Nakada)nobu@ruby-lang.org
<ul></ul><p>vadimp (Vadim Peretokin) wrote:</p>
<blockquote>
<pre><code>3rdparty/edbee-lib/vendor/onig/config.h:109:22: note: expanded from macro 'SIZEOF_VOIDP'
</code></pre>
</blockquote>
<p>What is this file?<br>
Do you mix different oniguruma?</p> Ruby master - Misc #16025: 'st_check_for_sizeof_st_index_t' declared as array with a negative size (emscripten)https://bugs.ruby-lang.org/issues/16025?journal_id=801622019-07-29T07:07:49Zk_takata (Ken Takata)
<ul></ul><p>Original discussion at here: <a href="https://github.com/k-takata/Onigmo/issues/130" class="external">https://github.com/k-takata/Onigmo/issues/130</a><br>
I think it's better to fix this in Ruby rather than in Onigmo.</p>
<p>I can suggest two ways.</p>
<p>1. Add <code>#ifndef</code> around <code>st_check_for_sizeof_st_index_t</code></p>
<pre><code class="diff syntaxhl" data-language="diff"><span class="gd">--- a/include/ruby/st.h
</span><span class="gi">+++ b/include/ruby/st.h
</span><span class="p">@@ -55,7 +55,9 @@</span> typedef st_data_t st_index_t;
typedef int st_compare_func(st_data_t, st_data_t);
typedef st_index_t st_hash_func(st_data_t);
<span class="gi">+#ifndef __EMSCRIPTEN__
</span> typedef char st_check_for_sizeof_st_index_t[SIZEOF_VOIDP == (int)sizeof(st_index_t) ? 1 : -1];
<span class="gi">+#endif
</span> #define SIZEOF_ST_INDEX_T SIZEOF_VOIDP
struct st_hash_type {
</code></pre>
<p>2. Remove <code>st_check_for_sizeof_st_index_t</code></p>
<p>The size of <code>void*</code> and <code>long</code> or <code>long long</code> are already checked at here:<br>
<a href="https://github.com/ruby/ruby/blob/8c6f1715f03e0322c96d614a42c30bee0b7790eb/include/ruby/st.h#L21-L27" class="external">https://github.com/ruby/ruby/blob/8c6f1715f03e0322c96d614a42c30bee0b7790eb/include/ruby/st.h#L21-L27</a><br>
Checking the size of <code>st_index_t</code> might be redundant.</p> Ruby master - Misc #16025: 'st_check_for_sizeof_st_index_t' declared as array with a negative size (emscripten)https://bugs.ruby-lang.org/issues/16025?journal_id=802662019-07-30T08:23:58Zko1 (Koichi Sasada)
<ul><li><strong>Status</strong> changed from <i>Open</i> to <i>Assigned</i></li><li><strong>Assignee</strong> set to <i>nobu (Nobuyoshi Nakada)</i></li></ul> Ruby master - Misc #16025: 'st_check_for_sizeof_st_index_t' declared as array with a negative size (emscripten)https://bugs.ruby-lang.org/issues/16025?journal_id=802762019-07-30T11:20:08Znobu (Nobuyoshi Nakada)nobu@ruby-lang.org
<ul></ul><p>k_takata (Ken Takata) wrote:</p>
<blockquote>
<p>2. Remove <code>st_check_for_sizeof_st_index_t</code></p>
<p>The size of <code>void*</code> and <code>long</code> or <code>long long</code> are already checked at here:<br>
<a href="https://github.com/ruby/ruby/blob/8c6f1715f03e0322c96d614a42c30bee0b7790eb/include/ruby/st.h#L21-L27" class="external">https://github.com/ruby/ruby/blob/8c6f1715f03e0322c96d614a42c30bee0b7790eb/include/ruby/st.h#L21-L27</a><br>
Checking the size of <code>st_index_t</code> might be redundant.</p>
</blockquote>
<p>This failure means the size of <code>st_index_t</code> doesn't equal the size of <code>void*</code>, so this check was not redundant actually.</p>