From ca38a3806c24f44e596187e9c9865f5bd7dd06bb Mon Sep 17 00:00:00 2001 From: redi Date: Fri, 22 Jan 2016 21:15:41 +0000 Subject: Constrain std::valarray functions and operators PR libstdc++/69116 * include/bits/valarray_before.h (__fun, __fun_with_valarray): Only define result_type for types which can be safely used with valarrays. * testsuite/26_numerics/valarray/69116.cc: New. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@232748 138bc75d-0d04-0410-961f-82ee72b054a4 --- .../testsuite/26_numerics/valarray/69116.cc | 53 ++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 libstdc++-v3/testsuite/26_numerics/valarray/69116.cc (limited to 'libstdc++-v3/testsuite/26_numerics') diff --git a/libstdc++-v3/testsuite/26_numerics/valarray/69116.cc b/libstdc++-v3/testsuite/26_numerics/valarray/69116.cc new file mode 100644 index 00000000000..ef9826778cf --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/valarray/69116.cc @@ -0,0 +1,53 @@ +// Copyright (C) 2016 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 3, 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 COPYING3. If not see +// . + +// { dg-do compile } +// { dg-options "-std=gnu++98" } + +// libstdc++/69116 + +#include +#include + +template + void foo(const T&) { } + +struct X : std::exception // makes namespace std an associated namespace +{ + virtual void pure() = 0; + + typedef void(*func_type)(const X&); + + void operator+(func_type) const; + void operator-(func_type) const; + void operator*(func_type) const; + void operator/(func_type) const; + void operator%(func_type) const; + void operator<<(func_type) const; + void operator>>(func_type) const; +}; + +void foo(X& x) +{ + x + foo; + x - foo; + x * foo; + x / foo; + x % foo; + x << foo; + x >> foo; +} -- cgit v1.2.1