Backport #7946

1.9.3-p385以降でclangでのビルド時にエラー(error: implicit conversion loses integer precision)

Added by Isao Sugimoto about 1 year ago. Updated about 1 year ago.

[ruby-dev:47096]
Status:Closed
Priority:High
Assignee:Usaku NAKAMURA

Description

=begin

OS X 10.8.2でclangでビルドを行う際にruby 1.9.3-p385以降でclangでコンパイル時にエラーとなるようになりました。

バグとのことですので報告します。
1.9.3-p385 および 1.9.3-p392 で発生します。

 BUILD FAILED

 Inspect or clean up the working tree at /var/folders/t0/n008mdzj4nz0_cswflz6xwch0000gn/T/ruby-build.20130223143931.52037
 Results logged to /var/folders/t0/n008mdzj4nz0_cswflz6xwch0000gn/T/ruby-build.20130223143931.52037.log

 Last 10 log lines:
 compiling safe.c
 compiling signal.c
 compiling sprintf.c
 compiling st.c
 st.c:520:35: error: implicit conversion loses integer precision: 'st_index_t' (aka 'unsigned long') to 'int' [-Werror,-Wshorten-64-to-32]
             i = table->num_entries++;
               ~ ~~~~~~~~~~~~~~~~~~^~
 1 error generated.
 make: *** [st.o] Error 1
 make: *** Waiting for unfinished jobs....

clangのバージョンなど

 $ clang -v
 Apple LLVM version 4.2 (clang-425.0.24) (based on LLVM 3.2svn)
 Target: x86_64-apple-darwin12.2.1
 Thread model: posix

参考 http://qiita.com/items/e7c4374d25ba2056a7b7

=end


Related issues

Related to ruby-trunk - Bug #7938: Stack consistency error while compiling 2.0.0-p0 Third Party's Issue 02/24/2013

Associated revisions

Revision 39503
Added by Usaku NAKAMURA about 1 year ago

  • st.c (stadddirect): int is not always same with stindext. some
    version of clang reports error.

  • thread.c (vmlivingthread_num): ditto.
    reported by d6rkaiz (Isao Sugimoto) at
    [Backport #7946]

History

#1 Updated by Shota Fukumori about 1 year ago

  • Assignee set to Kenta Murata

#2 Updated by Yui NARUSE about 1 year ago

I noticed that clang version 4.1 doesn't fail.

% clang --version
Apple clang version 4.1 (tags/Apple/clang-421.11.66) (based on LLVM 3.1svn)
Target: x86_64-apple-darwin12.2.1
Thread model: posix

But clang version 4.2 fails.

% clang --version
Apple LLVM version 4.2 (clang-425.0.24) (based on LLVM 3.2svn)
Target: x86_64-apple-darwin12.2.1
Thread model: posix

Anyway Ruby should avoid this.

#3 Updated by Yui NARUSE about 1 year ago

  • Tracker changed from Bug to Backport
  • Project changed from ruby-trunk to Backport93
  • Status changed from Open to Assigned
  • Assignee changed from Kenta Murata to Usaku NAKAMURA
  • Priority changed from Normal to High

1.9.3 のみに影響します。以下のパッチで回避できます。

Index: st.c

--- st.c (revision 39476)
+++ st.c (working copy)
@@ -515,7 +515,7 @@
stindext hashval, binpos;

 if (table->entries_packed) {
  • int i;
  • stindext i; if (MOREPACKABLEP(table)) { i = table->numentries++; table->bins[i*2] = (struct sttableentry*)key; Index: thread.c =================================================================== --- thread.c (revision 39476) +++ thread.c (working copy) @@ -2161,7 +2161,7 @@ static int vmlivingthreadnum(rbvmt *vm) {
  • return vm->livingthreads->numentries;
  • return (int)vm->livingthreads->numentries;
    }

    int

#4 Updated by Usaku NAKAMURA about 1 year ago

  • Status changed from Assigned to Closed
  • % Done changed from 0 to 100

This issue was solved with changeset r39503.
Isao, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.


  • st.c (stadddirect): int is not always same with stindext. some
    version of clang reports error.

  • thread.c (vmlivingthread_num): ditto.
    reported by d6rkaiz (Isao Sugimoto) at
    [Backport #7946]

Also available in: Atom PDF