Backport #7946

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

Added by Isao Sugimoto over 2 years ago. Updated over 2 years ago.

[ruby-dev:47096]
Status:Closed
Priority:Normal
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 over 2 years ago

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

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

History

#1 Updated by Shota Fukumori over 2 years ago

  • Assignee set to Kenta Murata

#2 Updated by Yui NARUSE over 2 years 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 over 2 years ago

  • Priority changed from Normal to 5
  • Status changed from Open to Assigned
  • Assignee changed from Kenta Murata to Usaku NAKAMURA
  • Tracker changed from Bug to Backport
  • Project changed from Ruby trunk to Backport193

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

Index: st.c

--- st.c (revision 39476)
+++ st.c (working copy)
@@ -515,7 +515,7 @@
st_index_t hash_val, bin_pos;

 if (table->entries_packed) {
  • int i;
  • st_index_t i; if (MORE_PACKABLE_P(table)) { i = table->num_entries++; table->bins[i*2] = (struct st_table_entry*)key; Index: thread.c =================================================================== --- thread.c (revision 39476) +++ thread.c (working copy) @@ -2161,7 +2161,7 @@ static int vm_living_thread_num(rb_vm_t *vm) {
  • return vm->living_threads->num_entries;
  • return (int)vm->living_threads->num_entries; }

int

#4 Updated by Usaku NAKAMURA over 2 years ago

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

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 (st_add_direct): int is not always same with st_index_t. some
    version of clang reports error.

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

Also available in: Atom PDF