Bug #2247: Fixing compiler warnings
http://redmine.ruby-lang.org/issues/show/2247

Author: ???????? T.
Status: Open, Priority: Normal
Category: build
ruby -v: ruby 1.8.7 (2009-06-12 patchlevel 174) [x86_64-linux]

When debugging a problem, gratuitous compiler warnings often get in the way by obscuring real problems.

This is why projects should try to eliminate them -- so that when a new one pops up, such as when new code is added, or the build is performed on a new platform -- the issue can attract its due attention.

The attached patch fixes warnings, that I observed compiling with ``-Wall -Werror'' on RHEL-5.4/x86_64 system. Please, consider merging these changes in.

The addressed problems are:

 * rb_thread_join was not declared (intern.h) with the rest of the rb_thread functions. Private declarations
   existed in some C-files...
 * The PUSH_FRAME duly defined the local variable _frame as volatile. However, when the value of _frame was
   assigned to the global ruby_frame, this qualifier was lost. There were as many warnings about this, as
   there are invocations of the PUSH_FRAME macro.
 * The little thread_timer() function MUST be declared as returning void*, because it is passed to
   pthread_create(). Compiler warned, that a non-void function lacked the return-statement. I added one...
 * regex.c in its error reporting tried to print ptrdiff_t value as int. On 64-bit platforms ptrdiff_t is,
   usually, long int, but that's an impossibly large value for a regular expression's length.
   Explicit casting of the pointer-difference down to int should be fine.
 * parse.y defined an unused static function arg_prepend()

Also, when compiling with a recent gcc at optimization level -O2 (or higher), util.c throws a number of warnings about breaking strict-aliasing rules. There is no /easy/ fix for this, but the work-around is to simply compile that one file with -fno-strict-aliasing (or whatever flag is needed for this with non-gcc compilers). A /sample/ patch for this issue is attached separately.

Thanks! Yours,

        -mi


----------------------------------------
http://redmine.ruby-lang.org