From d012ab6057968dd5235a64c03c2824ee6e80eea4 Mon Sep 17 00:00:00 2001 From: Edward Smith-Rowland <3dw4rd@verizon.net> Date: Tue, 4 Dec 2018 16:26:39 +0000 Subject: [PATCH] PR libstdc++/88341 - Complex norm doesn't compile with C++11 2018-12-03 Edward Smith-Rowland <3dw4rd@verizon.net> PR libstdc++/88341 - Complex norm doesn't compile with C++11 * include/std/complex (_S_do_it): Make C++20 constexpr. * testsuite/26_numerics/complex/value_operations/pr88341.cc: New test. From-SVN: r266788 --- libstdc++-v3/ChangeLog | 6 +++++ libstdc++-v3/include/std/complex | 4 +-- .../complex/value_operations/pr88341.cc | 27 +++++++++++++++++++ 3 files changed, 35 insertions(+), 2 deletions(-) create mode 100644 libstdc++-v3/testsuite/26_numerics/complex/value_operations/pr88341.cc diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 73d5b1c460e..bfc1ae7fe59 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,9 @@ +2018-12-03 Edward Smith-Rowland <3dw4rd@verizon.net> + + PR libstdc++/88341 - Complex norm doesn't compile with C++11 + * include/std/complex (_S_do_it): Make C++20 constexpr. + * testsuite/26_numerics/complex/value_operations/pr88341.cc: New test. + 2018-11-30 Edward Smith-Rowland <3dw4rd@verizon.net> Implement P0457R2 String Prefix and Suffix Checking. diff --git a/libstdc++-v3/include/std/complex b/libstdc++-v3/include/std/complex index b30346203b1..118dc2b49aa 100644 --- a/libstdc++-v3/include/std/complex +++ b/libstdc++-v3/include/std/complex @@ -659,7 +659,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION struct _Norm_helper { template - static inline _GLIBCXX_CONSTEXPR _Tp _S_do_it(const complex<_Tp>& __z) + static inline _GLIBCXX20_CONSTEXPR _Tp _S_do_it(const complex<_Tp>& __z) { const _Tp __x = __z.real(); const _Tp __y = __z.imag(); @@ -671,7 +671,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION struct _Norm_helper { template - static inline _GLIBCXX_CONSTEXPR _Tp _S_do_it(const complex<_Tp>& __z) + static inline _GLIBCXX20_CONSTEXPR _Tp _S_do_it(const complex<_Tp>& __z) { //_Tp __res = std::abs(__z); //return __res * __res; diff --git a/libstdc++-v3/testsuite/26_numerics/complex/value_operations/pr88341.cc b/libstdc++-v3/testsuite/26_numerics/complex/value_operations/pr88341.cc new file mode 100644 index 00000000000..dc928afa375 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/complex/value_operations/pr88341.cc @@ -0,0 +1,27 @@ +// { dg-options "-std=gnu++11" } +// { dg-do compile { target c++11 } } + +// Copyright (C) 2018 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 +// . + +#include + +double +n(std::complex& c) +{ + return std::norm(c); +}