Blame SOURCES/gcc48-pr69116.patch

56d343
2016-02-10  Jonathan Wakely  <jwakely@redhat.com>
56d343
56d343
	PR libstdc++/69116
56d343
	* include/bits/valarray_before.h (__fun, __fun_with_valarray): Only
56d343
	define result_type for types which can be safely used with valarrays.
56d343
	* testsuite/26_numerics/valarray/69116.cc: New.
56d343
56d343
--- libstdc++-v3/include/bits/valarray_before.h	(revision 233264)
56d343
+++ libstdc++-v3/include/bits/valarray_before.h	(revision 233265)
56d343
@@ -331,14 +331,24 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
56d343
       { return pow(__x, __y); }
56d343
   };
56d343
 
56d343
+  template<typename _Tp, bool _IsValidValarrayValue = !__is_abstract(_Tp)>
56d343
+    struct __fun_with_valarray
56d343
+    {
56d343
+      typedef _Tp result_type;
56d343
+    };
56d343
+
56d343
+  template<typename _Tp>
56d343
+    struct __fun_with_valarray<_Tp, false>
56d343
+    {
56d343
+      // No result type defined for invalid value types.
56d343
+    };
56d343
 
56d343
   // We need these bits in order to recover the return type of
56d343
   // some functions/operators now that we're no longer using
56d343
   // function templates.
56d343
   template<typename, typename _Tp>
56d343
-    struct __fun
56d343
+    struct __fun : __fun_with_valarray<_Tp>
56d343
     {
56d343
-      typedef _Tp result_type;
56d343
     };
56d343
 
56d343
   // several specializations for relational operators.
56d343
--- libstdc++-v3/testsuite/26_numerics/valarray/69116.cc	(nonexistent)
56d343
+++ libstdc++-v3/testsuite/26_numerics/valarray/69116.cc	(revision 233265)
56d343
@@ -0,0 +1,53 @@
56d343
+// Copyright (C) 2016 Free Software Foundation, Inc.
56d343
+//
56d343
+// This file is part of the GNU ISO C++ Library.  This library is free
56d343
+// software; you can redistribute it and/or modify it under the
56d343
+// terms of the GNU General Public License as published by the
56d343
+// Free Software Foundation; either version 3, or (at your option)
56d343
+// any later version.
56d343
+
56d343
+// This library is distributed in the hope that it will be useful,
56d343
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
56d343
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
56d343
+// GNU General Public License for more details.
56d343
+
56d343
+// You should have received a copy of the GNU General Public License along
56d343
+// with this library; see the file COPYING3.  If not see
56d343
+// <http://www.gnu.org/licenses/>.
56d343
+
56d343
+// { dg-do compile }
56d343
+// { dg-options "-std=gnu++98" }
56d343
+
56d343
+// libstdc++/69116
56d343
+
56d343
+#include <exception>
56d343
+#include <valarray>
56d343
+
56d343
+template<typename T>
56d343
+  void foo(const T&) { }
56d343
+
56d343
+struct X : std::exception // makes namespace std an associated namespace
56d343
+{
56d343
+  virtual void pure() = 0;
56d343
+
56d343
+  typedef void(*func_type)(const X&);
56d343
+
56d343
+  void operator+(func_type) const;
56d343
+  void operator-(func_type) const;
56d343
+  void operator*(func_type) const;
56d343
+  void operator/(func_type) const;
56d343
+  void operator%(func_type) const;
56d343
+  void operator<<(func_type) const;
56d343
+  void operator>>(func_type) const;
56d343
+};
56d343
+
56d343
+void foo(X& x)
56d343
+{
56d343
+  x + foo;
56d343
+  x - foo;
56d343
+  x * foo;
56d343
+  x / foo;
56d343
+  x % foo;
56d343
+  x << foo;
56d343
+  x >> foo;
56d343
+}