PR libstdc++/85930 fix misaligned reference

Message ID 20180604160642.GA13941@redhat.com
State New
Headers show
Series
  • PR libstdc++/85930 fix misaligned reference
Related show

Commit Message

Jonathan Wakely June 4, 2018, 4:06 p.m.
PR libstdc++/85930
	* include/bits/shared_ptr_base.h (_Sp_make_shared_tag::_S_ti): Align
	the static variable correctly.

Tested powerpc64le-linux, committed to trunk.
commit b0aa443f66d21f904ea0144b16df4b14ef9df09c
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Mon Jun 4 16:45:42 2018 +0100

    PR libstdc++/85930 fix misaligned reference
    
            PR libstdc++/85930
            * include/bits/shared_ptr_base.h (_Sp_make_shared_tag::_S_ti): Align
            the static variable correctly.

Comments

Jonathan Wakely June 4, 2018, 9:39 p.m. | #1
On 04/06/18 17:06 +0100, Jonathan Wakely wrote:
>	PR libstdc++/85930

>	* include/bits/shared_ptr_base.h (_Sp_make_shared_tag::_S_ti): Align

>	the static variable correctly.

>


And _really_ align it this time, so the alignment-specifier isn't
ignored (with the warning suppressed because it's a system header).

Tested powerpc64le-linux, committed to trunk.
commit 1efe054e03151e0fb53cacb937979f238e531ae1
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Mon Jun 4 22:25:50 2018 +0100

    PR libstdc++/85930 fix misplaced alignment-specifier
    
            PR libstdc++/85930
            * include/bits/shared_ptr_base.h [!__cpp_rtti]: Include <typeinfo>
            unconditionally. Remove redundant declaration.
            [!__cpp_rtti] (_Sp_make_shared_tag::_S_ti): Fix location of
            alignment-specifier.

diff --git a/libstdc++-v3/include/bits/shared_ptr_base.h b/libstdc++-v3/include/bits/shared_ptr_base.h
index 22cb7eb46b1..6c5089afdda 100644
--- a/libstdc++-v3/include/bits/shared_ptr_base.h
+++ b/libstdc++-v3/include/bits/shared_ptr_base.h
@@ -49,9 +49,7 @@
 #ifndef _SHARED_PTR_BASE_H
 #define _SHARED_PTR_BASE_H 1
 
-#if __cpp_rtti
-# include <typeinfo>
-#endif
+#include <typeinfo>
 #include <bits/allocated_ptr.h>
 #include <bits/refwrap.h>
 #include <bits/stl_function.h>
@@ -59,10 +57,6 @@
 
 namespace std _GLIBCXX_VISIBILITY(default)
 {
-#if !__cpp_rtti
-  class type_info;
-#endif
-
 _GLIBCXX_BEGIN_NAMESPACE_VERSION
 
 #if _GLIBCXX_USE_DEPRECATED
@@ -516,7 +510,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
     static const type_info&
     _S_ti() noexcept
     {
-      static constexpr alignas(type_info) _Sp_make_shared_tag __tag;
+      alignas(type_info) static constexpr _Sp_make_shared_tag __tag;
       return reinterpret_cast<const type_info&>(__tag);
     }
 #endif

Patch

diff --git a/libstdc++-v3/include/bits/shared_ptr_base.h b/libstdc++-v3/include/bits/shared_ptr_base.h
index b58273a79c5..22cb7eb46b1 100644
--- a/libstdc++-v3/include/bits/shared_ptr_base.h
+++ b/libstdc++-v3/include/bits/shared_ptr_base.h
@@ -516,7 +516,7 @@  _GLIBCXX_BEGIN_NAMESPACE_VERSION
     static const type_info&
     _S_ti() noexcept
     {
-      static constexpr _Sp_make_shared_tag __tag;
+      static constexpr alignas(type_info) _Sp_make_shared_tag __tag;
       return reinterpret_cast<const type_info&>(__tag);
     }
 #endif