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

ruby-changes:57686

From: =E5=8D=9C=E9=83=A8=E6=98=8C=E5=B9=B3 <ko1@a...>
Date: Mon, 9 Sep 2019 21:35:38 +0900 (JST)
Subject: [ruby-changes:57686] 150f514e19 (master): workaround for C++ 98 const union problem.

https://git.ruby-lang.org/ruby.git/commit/?id=150f514e19

From 150f514e19125ce8239602dc9266c7f68166d671 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E5=8D=9C=E9=83=A8=E6=98=8C=E5=B9=B3?=
 <shyouhei@r...>
Date: Mon, 9 Sep 2019 11:13:31 +0900
Subject: workaround for C++ 98 const union problem.

Not the case of recent compilers, but compilers before C++11
rejected ruby.h, like https://ci.appveyor.com/project/ruby/ruby/builds/27225706/job/qjca7dpe204dytbd

This is supposedly because a struct with a member qualified with
a const effectively deletes its default copy constructor, which
is considered as being user-defined somehow.  Not sure where
exactly is the phrase in the C++98 standard who allows such C /
C++ incompatibility though.

diff --git a/include/ruby/ruby.h b/include/ruby/ruby.h
index 445b2cd..0bede6f 100644
--- a/include/ruby/ruby.h
+++ b/include/ruby/ruby.h
@@ -1054,7 +1054,12 @@ struct RArray { https://github.com/ruby/ruby/blob/trunk/include/ruby/ruby.h#L1054
 	    long len;
 	    union {
 		long capa;
-                const VALUE shared_root;
+#if defined(__clang__)      /* <- clang++ is sane */ || \
+    !defined(__cplusplus)   /* <- C99 is sane */     || \
+    (__cplusplus > 199711L) /* <- C++11 is sane */
+                const
+#endif
+                VALUE shared_root;
 	    } aux;
 	    const VALUE *ptr;
 	} heap;
-- 
cgit v0.10.2


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

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