Groogy / rbSFML

Ruby bindings to SFML
Other
44 stars 5 forks source link

ext/System/Vector2.hpp build broken on OS X x86_64 with Clang #49

Closed jashank closed 8 years ago

jashank commented 11 years ago

Trying to build rbSFML at revision f8297fb48d on Darwin/OS X 10.7, x86_64, with Clang/LLVM.

Compiling ./ext/System/Vector2.cpp
In file included from ./ext/System/Vector2.cpp:24:
./ext/System/Vector2.hpp:123:39: error: implicit conversion loses integer precision: 'long' to 'int' [-Wshorten-64-to-32]
        return rb_class_new_instance( RARRAY_LEN( anOther ), RARRAY_PTR( anOther ),
                                      ^~~~~~~~~~~~~~~~~~~~~
/Users/jashank/.rvm/rubies/ruby-1.9.3-p392/include/ruby-1.9.1/ruby/ruby.h:711:6: note: instantiated from:
     (long)((RBASIC(a)->flags >> RARRAY_EMBED_LEN_SHIFT) & \
     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from ./ext/System/Vector2.cpp:24:
./ext/System/Vector2.hpp:123:39: error: implicit conversion loses integer precision: 'long' to 'int' [-Wshorten-64-to-32]
        return rb_class_new_instance( RARRAY_LEN( anOther ), RARRAY_PTR( anOther ),
                                      ^~~~~~~~~~~~~~~~~~~~~
/Users/jashank/.rvm/rubies/ruby-1.9.3-p392/include/ruby-1.9.1/ruby/ruby.h:713:25: note: instantiated from:
     RARRAY(a)->as.heap.len)
                        ^
2 errors generated.
rake aborted!

And no, GCC doesn't produce this error, but the resultant bundles cause Ruby to reliably segfault.

Groogy commented 11 years ago

I'll fix those but I don't understand why this would cause Ruby to reliably segfault.

jashank commented 11 years ago

Plausibly, the truncation is occurring on values used for addressing, but I don't understand enough about the way YARV's extension handling works to be certain. Also, I don't know why GCC just flags a warning when Clang raises an error. There are cases of this in

As for the segfault itself, I can reliably reproduce it; I uploaded a Ruby backtrace and the matching crash log from OS X.

Groogy commented 11 years ago

They are not values that are used for addressing. What it is complaining about is just a simple number that describes how many elements there are in the array, nothing more and nothing less. From the crash log it looked like it crashed when sfml/all are requiring sfml/system

After I've fixed these when I get home from work you should try again and if it still fails you should file it as a new issue.

Groogy commented 11 years ago

Fixed the implicit casting in the Vector files. Can you give me some more warnings?

jashank commented 11 years ago

I ran the build using GCC and got some warnings; here's the build log.