[前][次][番号順一覧][スレッド一覧]

ruby-changes:42842

From: nobu <ko1@a...>
Date: Thu, 5 May 2016 15:14:57 +0900 (JST)
Subject: [ruby-changes:42842] nobu:r54916 (trunk): proc.c: suppress a warning

nobu	2016-05-05 16:11:34 +0900 (Thu, 05 May 2016)

  New Revision: 54916

  https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=54916

  Log:
    proc.c: suppress a warning
    
    * proc.c (call_method_data_safe): suppress clobbered warning by
      old gcc.

  Modified files:
    trunk/proc.c
Index: proc.c
===================================================================
--- proc.c	(revision 54915)
+++ proc.c	(revision 54916)
@@ -18,6 +18,12 @@ https://github.com/ruby/ruby/blob/trunk/proc.c#L18
  * versions */
 #define PROC_NEW_REQUIRES_BLOCK 0
 
+#if !defined(__GNUC__) || __GNUC__ < 5
+# define NO_CLOBBERED(v) (*(volatile VALUE *)&(v))
+#else
+# define NO_CLOBBERED(v) (v)
+#endif
+
 const rb_cref_t *rb_vm_cref_in_context(VALUE self, VALUE cbase);
 
 struct METHOD {
@@ -1980,7 +1986,9 @@ call_method_data_safe(rb_thread_t *th, c https://github.com/ruby/ruby/blob/trunk/proc.c#L1986
 
     TH_PUSH_TAG(th);
     if ((state = TH_EXEC_TAG()) == 0) {
-	result = call_method_data(th, data, argc, argv, pass_procval);
+	/* result is used only if state == 0, no exceptions is caught. */
+	/* otherwise it doesn't matter even if clobbered. */
+	NO_CLOBBERED(result) = call_method_data(th, data, argc, argv, pass_procval);
     }
     TH_POP_TAG();
     rb_set_safe_level_force(safe);

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]