From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 71804 invoked by alias); 27 Nov 2018 06:46:04 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 71411 invoked by uid 89); 27 Nov 2018 06:45:45 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-8.4 required=5.0 tests=BAYES_00,GIT_PATCH_2,GIT_PATCH_3,RCVD_IN_DNSWL_NONE,SEM_URI,SEM_URIRED,SPF_PASS,TIME_LIMIT_EXCEEDED autolearn=unavailable version=3.3.2 spammy= X-HELO: mail-vs1-f53.google.com Received: from mail-vs1-f53.google.com (HELO mail-vs1-f53.google.com) (209.85.217.53) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 27 Nov 2018 06:45:27 +0000 Received: by mail-vs1-f53.google.com with SMTP id y27so13100870vsi.1 for ; Mon, 26 Nov 2018 22:45:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=N32eOeiYOQFJc3lau11SPuaKRu5t4DZiXOROd91QYiE=; b=IdzF7igNzjJ/Eu58t6YAGrOmlyht1EUm/ohTEYvYd0bjNW8RUmQh70Z7fVyW0CcRjQ rcoNMY1JfL7wloCQ7Wu9V2NZKbgbaOtvNwVuldY6zyqO0OZt3vYwxS3fh0fIlnPwsvDl SHh7/qEwJmPOjia2FaNCQvD9mCT7DFBU99aOU= MIME-Version: 1.0 References: <5e2b3a30-fd0c-351d-256c-b70e060d4994@verizon.net> <25862c9d-87f6-9f86-aad5-e1bf9e632d35@verizon.net> <4b33abf3-cf67-8c62-5b1d-c06da4d97748@verizon.net> <20181119111300.GP28365@redhat.com> <20181122091959.GF28365@redhat.com> <20181126111237.GO28365@redhat.com> In-Reply-To: <20181126111237.GO28365@redhat.com> From: Christophe Lyon Date: Tue, 27 Nov 2018 06:46:00 -0000 Message-ID: Subject: Re: [PATCH, libstdc++] Implement P0415 More constexpr for std::complex. To: Jonathan Wakely Cc: Ed Smith-Rowland <3dw4rd@verizon.net>, daniel.kruegler@gmail.com, libstdc++@gcc.gnu.org, gcc Patches Content-Type: text/plain; charset="UTF-8" X-IsSubscribed: yes X-SW-Source: 2018-11/txt/msg02166.txt.bz2 On Mon, 26 Nov 2018 at 12:12, Jonathan Wakely wrote: > > On 26/11/18 09:30 +0100, Christophe Lyon wrote: > >On Thu, 22 Nov 2018 at 10:20, Jonathan Wakely wrote: > >> > >> On 20/11/18 17:58 -0500, Ed Smith-Rowland wrote: > >> >On 11/19/18 6:13 AM, Jonathan Wakely wrote: > >> >>On 16/11/18 19:39 -0500, Ed Smith-Rowland wrote: > >> >>>@@ -322,67 +323,43 @@ > >> >>> //@{ > >> >>> /// Return new complex value @a x plus @a y. > >> >>> template > >> >>>- inline complex<_Tp> > >> >>>+ inline _GLIBCXX20_CONSTEXPR complex<_Tp> > >> >>> operator+(const complex<_Tp>& __x, const complex<_Tp>& __y) > >> >>>- { > >> >>>- complex<_Tp> __r = __x; > >> >>>- __r += __y; > >> >>>- return __r; > >> >>>- } > >> >>>+ { return complex<_Tp>(__x.real() + __y.real(), __x.imag() + > >> >>>__y.imag()); } > >> >> > >> >>Is this change (and all the similar ones) really needed? > >> >> > >> >>Doesn't the fact that all the constructors and member operators of > >> >>std::complex mean that the original definition is also valid in a > >> >>constexpr function? > >> >These changes are rolled back. Sorry. > >> >>>@@ -1163,50 +1143,43 @@ > >> >>>#endif > >> >>> > >> >>> template > >> >>>- complex& > >> >>>+ _GLIBCXX20_CONSTEXPR complex& > >> >>> operator=(const complex<_Tp>& __z) > >> >>> { > >> >>>- __real__ _M_value = __z.real(); > >> >>>- __imag__ _M_value = __z.imag(); > >> >>>+ _M_value = __z.__rep(); > >> >> > >> >>These changes look OK, but I wonder if we shouldn't ask the compiler > >> >>to make it possible to use __real__ and __imag__ in constexpr > >> >>functions instead. > >> >> > >> >>I assume it doesn't, and that's why you made this change. But if it > >> >>Just Worked, and the other changes I commented on above are also > >> >>unnecessary, then this patch would *mostly* just be adding > >> >>_GLIBCXX20_CONSTEXPR which is OK for stage 3 (as it doesn't affect any > >> >>dialects except C++2a). > >> > > >> >Yes, this is the issue. I agree that constexpr _real__, __imag__would > >> >be better. > >> > > >> >Do you have any idea where this change would be? I grepped around a > >> >little and couldn't figure it out. if you don't I'll look more. > >> > >> No idea, sorry. > >> > >> >Actually, looking at constexpr.c it looks like the old way ought to work... > >> > > >> >OK, plain assignment works but not the others. Interesting. > >> > > >> >> > >> >>>@@ -1872,7 +1831,7 @@ > >> >>> { return _Tp(); } > >> >>> > >> >>> template > >> >>>- inline typename __gnu_cxx::__promote<_Tp>::__type > >> >>>+ _GLIBCXX_CONSTEXPR inline typename > >> >>>__gnu_cxx::__promote<_Tp>::__type > >> >> > >> >>This should be _GLIBCXX20_CONSTEXPR. > >> >Done. > >> >>>Index: > >> >>>testsuite/26_numerics/complex/comparison_operators/more_constexpr.cc > >> >>>=================================================================== > >> >>>--- > >> >>>testsuite/26_numerics/complex/comparison_operators/more_constexpr.cc > >> >>>(nonexistent) > >> >>>+++ > >> >>>testsuite/26_numerics/complex/comparison_operators/more_constexpr.cc > >> >>>(working copy) > >> >>>@@ -0,0 +1,51 @@ > >> >>>+// { dg-do compile { target c++2a } } > >> >> > >> >>All the tests with { target c++2a} should also have: > >> >> > >> >>// { dg-options "-std=gnu++2a" } > >> >> > >> >>Because otherwise they are skipped by default, and only get run when > >> >>RUNTESTFLAGS explicitly includes something like > >> >>--target_board=unix/-std=gnu++2a > >> >> > >> >>The dg-options needs to come first, or it doesn't apply before the > >> >>check for { target c++2a }. > >> >> > >> >Thank you, done. > >> > >> OK for trunk, thanks. > >> > >> >Updated patch attached. I'd like to understand why > >> > > >> > __real__ _M_value += __z.real(); > >> > > >> >doesn't work though. > >> > >> Yes, I agree it should. If you don't figure it out please file a bug > >> requesting that it works, so somebody else might look into it. > >> > > > >Hi, > >I have noticed that > >FAIL: 26_numerics/complex/requirements/more_constexpr.cc > >on arm and aarch64 > >The error messages: > >Excess errors: > >/libstdc++-v3/testsuite/26_numerics/complex/requirements/more_constexpr.cc:168: > >error: '__float128' was not declared in this scope > >/libstdc++-v3/testsuite/26_numerics/complex/requirements/more_constexpr.cc:168: > >error: no matching function for call to > >'test_operator_members<, __float128>()' > >/libstdc++-v3/testsuite/26_numerics/complex/requirements/more_constexpr.cc:168: > >error: template argument 1 is invalid > > Should be fixed by this patch, committed to trunk. > > Indeed, thanks.