Issue #7756 has been updated by drbrain (Eric Hodel).


=begin
This patch works:


  Index: vm_core.h
  ===================================================================
  --- vm_core.h	(revision 38980)
  +++ vm_core.h	(working copy)
  @@ -116,7 +116,7 @@
   #endif /* __GNUC__ >= 3 */
   
   #if __GNUC__ >= 3
  -#define UNINITIALIZED_VAR(x) x = x
  +#define UNINITIALIZED_VAR(x) x __attribute__((unused))
   #else
   #define UNINITIALIZED_VAR(x) x
   #endif
=end

----------------------------------------
Bug #7756: clang 3.2 sees through UNINITIALIZED_VAR macro, gives warning
https://bugs.ruby-lang.org/issues/7756#change-35710

Author: drbrain (Eric Hodel)
Status: Open
Priority: Normal
Assignee: 
Category: core
Target version: 2.0.0
ruby -v: -


=begin

In clang 3.2, the UNINITIALIZED_VAR macro does not prevent the compiler from producing a warning.

Apple clang 3.2:

  $ 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

When compiling thread.c:

  compiling ../trunk/thread.c
  ../trunk/thread.c:3261:34: warning: variable 'orig_read' is uninitialized when
        used within its own initialization [-Wuninitialized]
      rb_fdset_t UNINITIALIZED_VAR(orig_read);
                                   ^~~~~~~~~
  ../trunk/vm_core.h:119:34: note: expanded from macro 'UNINITIALIZED_VAR'
  #define UNINITIALIZED_VAR(x) x = x
                                   ^
  ../trunk/thread.c:3262:34: warning: variable 'orig_write' is uninitialized when
        used within its own initialization [-Wuninitialized]
      rb_fdset_t UNINITIALIZED_VAR(orig_write);
                                   ^~~~~~~~~~
  ../trunk/vm_core.h:119:34: note: expanded from macro 'UNINITIALIZED_VAR'
  #define UNINITIALIZED_VAR(x) x = x
                                   ^
  ../trunk/thread.c:3263:34: warning: variable 'orig_except' is uninitialized when
        used within its own initialization [-Wuninitialized]
      rb_fdset_t UNINITIALIZED_VAR(orig_except);
                                   ^~~~~~~~~~~
  ../trunk/vm_core.h:119:34: note: expanded from macro 'UNINITIALIZED_VAR'
  #define UNINITIALIZED_VAR(x) x = x
                                   ^
  3 warnings generated.

=end



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