+ compilerh-fix-c-uninitialized-const-issue.patch added to -mm tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The patch titled
     Subject: include/linux/compiler.h: fix C++ uninitialized const issue
has been added to the -mm tree.  Its filename is
     compilerh-fix-c-uninitialized-const-issue.patch

This patch should soon appear at
    http://ozlabs.org/~akpm/mmots/broken-out/compilerh-fix-c-uninitialized-const-issue.patch
and later at
    http://ozlabs.org/~akpm/mmotm/broken-out/compilerh-fix-c-uninitialized-const-issue.patch

Before you just go and hit "reply", please:
   a) Consider who else should be cc'ed
   b) Prefer to cc a suitable mailing list as well
   c) Ideally: find the original patch on the mailing list and do a
      reply-to-all to that, adding suitable additional cc's

*** Remember to use Documentation/SubmitChecklist when testing your code ***

The -mm tree is included into linux-next and is updated
there every 3-4 working days

------------------------------------------------------
From: Joakim Tjernlund <joakim.tjernlund@xxxxxxxxxxxx>
Subject: include/linux/compiler.h: fix C++ uninitialized const issue

C++ does not like the union { typeof(x) __val; char __c[1]; } __u
construct for const types:
 error: uninitialized const member in
 'union atomic_read(const atomic_t*)::<anonymous>'
Address this by creating a C++ version of READ_ONCE where this union is
initialized: union { void _u(){}; typeof(x) __val; char __c[1]; } __u={0}

To please gcc 6.3.0 also add in a _u(){} as default ctor.

This makes C++ happy enough to build.

Link: http://lkml.kernel.org/r/20170221151044.5499-2-joakim.tjernlund@xxxxxxxxxxxx
Signed-off-by: Joakim Tjernlund <joakim.tjernlund@xxxxxxxxxxxx>
Cc: <stable@xxxxxxxxxxxxxxx>
Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx>
---

 include/linux/compiler.h |   12 ++++++++++++
 1 file changed, 12 insertions(+)

diff -puN include/linux/compiler.h~compilerh-fix-c-uninitialized-const-issue include/linux/compiler.h
--- a/include/linux/compiler.h~compilerh-fix-c-uninitialized-const-issue
+++ a/include/linux/compiler.h
@@ -311,6 +311,7 @@ static __always_inline void __write_once
  * required ordering.
  */
 
+#ifndef __cplusplus
 #define __READ_ONCE(x, check)						\
 ({									\
 	union { typeof(x) __val; char __c[1]; } __u;			\
@@ -320,6 +321,17 @@ static __always_inline void __write_once
 		__read_once_size_nocheck(&(x), __u.__c, sizeof(x));	\
 	__u.__val;							\
 })
+#else
+#define __READ_ONCE(x, check)						\
+({									\
+	union { void _u(){}; typeof(x) __val; char __c[1]; } __u={0};	\
+	if (check)							\
+		__read_once_size(&(x), __u.__c, sizeof(x));		\
+	else								\
+		__read_once_size_nocheck(&(x), __u.__c, sizeof(x));	\
+	__u.__val;							\
+})
+#endif
 #define READ_ONCE(x) __READ_ONCE(x, 1)
 
 /*
_

Patches currently in -mm which might be from joakim.tjernlund@xxxxxxxxxxxx are

correct-function-definition-for-c.patch
compilerh-fix-c-uninitialized-const-issue.patch




[Index of Archives]     [Linux Kernel]     [Kernel Development Newbies]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite Hiking]     [Linux Kernel]     [Linux SCSI]