Bug #11644
closedSince r52055, TestMkmf::TestConvertible failed on Solaris 10 with fcc
Description
r52055以降、Solaris 10 上の古いfcc (Fujitsu C Compiler) にてコンパイルすると、
make test-all にて
TestMkmf::TestConvertible#test_typeof_builtin
TestMkmf::TestConvertible#test_typeof_typedef
がfailureになります。
長いのでFailure部分のログはファイル(r52055-failure.log)にて添付します。
以下のようにポインタの型の不一致のWarningが出ているのが原因でしょうか?
"/XXXXX-52055/include/ruby/ruby.h", line 2003: warning: return incompatible pointer types: expected `const VALUE *' actual `const unsigned long *' in function `rb_array_const_ptr'
"/XXXXX-52055/include/ruby/ruby.h", line 2017: warning: return incompatible pointer types: expected `const VALUE *' actual `const unsigned long *' in function `rb_struct_const_ptr'
なお、Oracle Solaris Studio 12.3 など他のコンパイラではFailureにならず成功しています。
Files
Updated by nobu (Nobuyoshi Nakada) over 8 years ago
- Status changed from Open to Feedback
r52055のinclude/ruby/ruby.h:2003は
RARRAY(a)->as.ary : RARRAY(a)->as.heap.ptr;
でどちらもconst VALUE *
のはずですが…。
それにVALUE
がunsigned long
とは違うということはIL32P64コンパイラでしょうか。
Updated by ngoto (Naohisa Goto) over 8 years ago
それにVALUEがunsigned longとは違うということはIL32P64コンパイラでしょうか。
いいえ、LP64 です。
コンパイラは const VALUE *
と const unsigned long *
が incompatible と主張していますが、そんなことはないはずなので、この点に関しては、コンパイラのバグかもしれません。
あるいは、コンパイラへのオプションが mkmf.rb 内部で削られて、32ビットモードでコンパイルしている可能性はあるかもしれません。
コンパイル時のコマンドラインを表示するのに良い方法は何かあるでしょうか?
Updated by nobu (Nobuyoshi Nakada) over 8 years ago
Naohisa Goto wrote:
あるいは、コンパイラへのオプションが mkmf.rb 内部で削られて、32ビットモードでコンパイルしている可能性はあるかもしれません。
コンパイル時のコマンドラインを表示するのに良い方法は何かあるでしょうか?
出してたはずと思ったら出てませんでした。
r52431で試してみてください。
Updated by ngoto (Naohisa Goto) over 8 years ago
コマンドラインは正常だったので、やはりWarningが出たのが原因のようです。
以下のようにキャストするとFailureは出なくなりました。
(三項演算子のどちらか片方だけのキャストではダメでした。)
しかし、古いバージョンのコンパイラのバグっぽい挙動のために、全環境でキャストを入れるのは、
将来の型変更時のミス等を隠蔽するため有害な気がするので、
#ifdef 等で環境・コンパイラを限定してキャストするのがよいかと思っています。
--- include/ruby/ruby.h~ 2015-11-02 23:46:44.317989704 +0900
+++ include/ruby/ruby.h 2015-11-03 20:27:45.085567608 +0900
@@ -2007,8 +2007,8 @@
static inline const VALUE *
rb_array_const_ptr(VALUE a)
{
- return (RBASIC(a)->flags & RARRAY_EMBED_FLAG) ?
- RARRAY(a)->as.ary : RARRAY(a)->as.heap.ptr;
+ return (const VALUE *)((RBASIC(a)->flags & RARRAY_EMBED_FLAG) ?
+ RARRAY(a)->as.ary : RARRAY(a)->as.heap.ptr);
}
static inline long
@@ -2021,8 +2021,8 @@
static inline const VALUE *
rb_struct_const_ptr(VALUE st)
{
- return (RBASIC(st)->flags & RSTRUCT_EMBED_LEN_MASK) ?
- RSTRUCT(st)->as.ary : RSTRUCT(st)->as.heap.ptr;
+ return (const VALUE *)((RBASIC(st)->flags & RSTRUCT_EMBED_LEN_MASK) ?
+ RSTRUCT(st)->as.ary : RSTRUCT(st)->as.heap.ptr);
}
#if defined(EXTLIB) && defined(USE_DLN_A_OUT)
Updated by ngoto (Naohisa Goto) over 8 years ago
- Status changed from Feedback to Closed
Applied in changeset r52465.
- include/ruby/ruby.h (rb_array_const_ptr, rb_struct_const_ptr):
Suppress pointer type mismatch warnings occurred with old version
of Fujitsu C Compiler (fcc) on Solaris 10. The warnings cause
failure of TestMkmf::TestConvertible. [Bug #11644] [ruby-dev:49326] - include/ruby/ruby.h (FIX_CONST_VALUE_PTR): macro for the above,
only effective with fcc.
Updated by ngoto (Naohisa Goto) about 8 years ago
- Related to Bug #12470: Since r54952, TestMkmf::TestConvertible failed on Solaris 10 with Oracle SolarisStudio 12.x cc added