This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

missing include guards on {bits,tr1}/shared_ptr.h


While trying to work out why shared_ptr doesn't appear in the doxygen
docs, I realised that include/bits/shared_ptr.h and
include/tr1/shared_ptr.h don't have any include guards.  This is
because I split include/tr1_impl/boost_shared_ptr.h into two separate
files, and I'm an idiot.

The tr1_impl/boost_shared_ptr.h file in GCC 4.3 and earlier cannot
have include guards, because it must be possible to include it twice,
once as C++0x and once as TR1.  That is not the case with the separate
files, which should have include guards.

This causes the following to break in -std=c++0x mode:

#include <memory>
#include <bits/shared_ptr.h>

or this in all modes:

#include <tr1/memory>
#include <tr1/shared_ptr.h>

This is not technically a regression, because those headers didn't
exist in GCC 4.3 and are not meant to be included by users anyway.
Should a fix wait for 4.4.1, or can it go in now?

The attached patch was tested on GNU/Linux x86_64.

Jon
Index: include/bits/shared_ptr.h
===================================================================
--- include/bits/shared_ptr.h	(revision 144705)
+++ include/bits/shared_ptr.h	(working copy)
@@ -51,6 +51,9 @@
  *  You should not attempt to use it directly.
  */
 
+#ifndef _SHARED_PTR_H
+#define _SHARED_PTR_H 1
+
 #ifndef __GXX_EXPERIMENTAL_CXX0X__
 # include <c++0x_warning.h>
 #endif
@@ -1589,3 +1592,5 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
   // @} group pointer_abstractions
 
 _GLIBCXX_END_NAMESPACE
+
+#endif // _SHARED_PTR_H
Index: include/tr1/shared_ptr.h
===================================================================
--- include/tr1/shared_ptr.h	(revision 144705)
+++ include/tr1/shared_ptr.h	(working copy)
@@ -51,6 +51,9 @@
  *  You should not attempt to use it directly.
  */
 
+#ifndef _TR1_SHARED_PTR_H
+#define _TR1_SHARED_PTR_H 1
+
 #if defined(_GLIBCXX_INCLUDE_AS_CXX0X)
 #  error TR1 header cannot be included from C++0x header
 #endif
@@ -1018,3 +1021,5 @@ namespace tr1
 
 }
 }
+
+#endif // _TR1_SHARED_PTR_H

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]