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