This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[libstdc++] Adaptor classes need out-of-line definitions
- From: Phil Edwards <phil at jaj dot com>
- To: libstdc++ at gcc dot gnu dot org, gcc-patches at gcc dot gnu dot org
- Date: Fri, 28 Jun 2002 21:11:04 -0400
- Subject: [libstdc++] Adaptor classes need out-of-line definitions
When I split the basic sequence classes (vector, list, deque) out into tcc
files two weeks ago, I didn't check that the adaptor classes which use
the sequence classes (queue, stack, priority_queue) still worked. Duh.
(Ah, for a fully-covering testsuite...) Thanks to Peter Schmid for finding
these bugs.
The fix of course is to include the sequence tcc files in the adaptor
classes headers, just like we do with the sequences.
Tested on i686-pc-linux-gnu. Applied to trunk.
2002-06-28 Phil Edwards <pme@gcc.gnu.org>
PR libstdc++/7157, PR libstdc++/7158, PR libstdc++/7161
* include/std/std_queue.h: Include deque.tcc, vector.tcc.
* include/std/std_stack.h: Include deque.tcc.
* testsuite/23_containers/adaptors.cc: New file.
Index: include/std/std_queue.h
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/include/std/std_queue.h,v
retrieving revision 1.2
diff -u -3 -p -r1.2 std_queue.h
--- include/std/std_queue.h 28 Jan 2002 22:13:11 -0000 1.2
+++ include/std/std_queue.h 29 Jun 2002 01:08:10 -0000
@@ -74,8 +74,9 @@
#include <bits/stl_function.h>
#include <bits/stl_queue.h>
-#endif /* _CPP_QUEUE */
+#ifdef _GLIBCPP_NO_TEMPLATE_EXPORT
+# include <bits/deque.tcc>
+# include <bits/vector.tcc>
+#endif
-// Local Variables:
-// mode:C++
-// End:
+#endif /* _CPP_QUEUE */
Index: include/std/std_stack.h
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/include/std/std_stack.h,v
retrieving revision 1.2
diff -u -3 -p -r1.2 std_stack.h
--- include/std/std_stack.h 28 Jan 2002 22:13:11 -0000 1.2
+++ include/std/std_stack.h 29 Jun 2002 01:08:10 -0000
@@ -70,8 +70,8 @@
#include <bits/stl_deque.h>
#include <bits/stl_stack.h>
-#endif /* _CPP_STACK */
+#ifdef _GLIBCPP_NO_TEMPLATE_EXPORT
+# include <bits/deque.tcc>
+#endif
-// Local Variables:
-// mode:C++
-// End:
+#endif /* _CPP_STACK */
Index: testsuite/23_containers/adaptors.cc
===================================================================
RCS file: testsuite/23_containers/adaptors.cc
diff -N testsuite/23_containers/adaptors.cc
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ testsuite/23_containers/adaptors.cc 29 Jun 2002 01:08:10 -0000
@@ -0,0 +1,79 @@
+// 2002-06-28 pme
+
+// Copyright (C) 2002 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 2, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING. If not, write to the Free
+// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+// USA.
+
+// 23.2.3 container adaptors
+
+#include <queue>
+#include <stack>
+#include <testsuite_hooks.h>
+
+// libstdc++/7157
+void
+test01()
+{
+ std::queue<int> q;
+
+ q.push(1);
+ q.front();
+ q.pop();
+}
+
+
+// libstdc++/7158
+void
+test02()
+{
+ std::stack<int> st;
+
+ st.push(1);
+ st.top() = 42;
+ st.pop();
+}
+
+
+// libstdc++/7161
+void
+test03()
+{
+ int data[] = {1, 2, 3};
+ std::priority_queue<int> pq;
+ std::size_t size = pq.size();
+
+ for (int i = 0; i < 3; ++i)
+ pq.push(data[i]);
+
+ size = pq.size();
+ pq.top();
+ for (int i = 0; i < 2; ++i)
+ pq.pop();
+
+ while (!pq.empty())
+ pq.pop();
+}
+
+
+int main()
+{
+ test01();
+ test02();
+ test03();
+
+ return 0;
+}