From: Jonathan Wakely <jwakely@redhat.com>
To: libstdc++@gcc.gnu.org
Cc: Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE>,
Jason Merrill <jason@redhat.com>,
Christophe Lyon <christophe.lyon@linaro.org>,
Andreas Schwab <schwab@linux-m68k.org>,
gcc-patches List <gcc-patches@gcc.gnu.org>
Subject: Re: RFA (libstdc++): PATCH to implement C++17 over-aligned new
Date: Fri, 16 Sep 2016 18:19:00 -0000 [thread overview]
Message-ID: <20160916180908.GQ17376@redhat.com> (raw)
In-Reply-To: <20160916121230.GP17376@redhat.com>
[-- Attachment #1: Type: text/plain, Size: 877 bytes --]
On 16/09/16 13:12 +0100, Jonathan Wakely wrote:
>On 16/09/16 11:56 +0100, Jonathan Wakely wrote:
>>On 16/09/16 11:37 +0200, Marc Glisse wrote:
>>>Is the division (by a non-constant denominator) really necessary?
>>
>>Probably not, but I've asked the committee for clarification what this
>>function should do when called with an invalid alignment.
>>
>>>Since align has to be a power of 2, x % align should be the same
>>>as x & (align - 1), for instance.
>>
>>Thanks, if it's UB to call it with alignments that aren't a power of
>>two then we can do that.
>
>I've committed the patch now, to fix the failures for Solaris. I'll
>revisit it when I get clarification from the committee about invalid
>alignment arguments.
I missed 18.6.2/1 which is clear that we don't have to support invalid
alignments passed to operator new, so I'm committing this.
Tested x86_64-linux.
[-- Attachment #2: patch.txt --]
[-- Type: text/x-patch, Size: 932 bytes --]
commit 0a70fa595953ff1e6e46266d7f86bc6d7e3400a4
Author: Jonathan Wakely <jwakely@redhat.com>
Date: Fri Sep 16 17:36:44 2016 +0100
Replace modulus with mask operation in over-aligned new
2016-09-16 Jonathan Wakely <jwakely@redhat.com>
Marc Glisse <marc.glisse@inria.fr>
* libsupc++/new_opa.cc [_GLIBCXX_HAVE_ALIGNED_ALLOC]
(operator new(size_t, align_val_t)): Replace modulus operator with
mask.
diff --git a/libstdc++-v3/libsupc++/new_opa.cc b/libstdc++-v3/libsupc++/new_opa.cc
index 9c859c1..91e53a8 100644
--- a/libstdc++-v3/libsupc++/new_opa.cc
+++ b/libstdc++-v3/libsupc++/new_opa.cc
@@ -69,7 +69,7 @@ operator new (std::size_t sz, std::align_val_t al)
#if _GLIBCXX_HAVE_ALIGNED_ALLOC
/* C11: the value of size shall be an integral multiple of alignment. */
- if (std::size_t rem = sz % align)
+ if (std::size_t rem = sz & (align - 1))
sz += align - rem;
#endif
next prev parent reply other threads:[~2016-09-16 18:09 UTC|newest]
Thread overview: 42+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-09-08 7:10 Jason Merrill
2016-09-08 8:32 ` Marc Glisse
2016-09-08 11:18 ` Jonathan Wakely
2016-09-09 21:40 ` Jason Merrill
2016-09-10 7:03 ` Christophe Lyon
2016-09-10 10:14 ` Marc Glisse
2016-09-10 10:35 ` Jonathan Wakely
2016-09-11 9:14 ` Christophe Lyon
2016-09-11 9:55 ` Jonathan Wakely
2016-09-11 9:56 ` Jonathan Wakely
2016-09-11 10:20 ` Christophe Lyon
2016-09-11 12:09 ` Jonathan Wakely
2016-09-13 13:04 ` Szabolcs Nagy
2016-09-10 10:14 ` Jonathan Wakely
2016-09-11 7:09 ` Andreas Schwab
2016-09-12 21:13 ` Jason Merrill
2016-09-13 8:41 ` Christophe Lyon
2016-09-13 12:37 ` Andreas Schwab
2016-09-13 12:54 ` Jason Merrill
2016-09-13 13:18 ` Andreas Schwab
2016-09-13 13:21 ` Jason Merrill
2016-09-14 12:13 ` Andreas Schwab
2016-09-14 16:11 ` Christophe Lyon
2016-09-14 16:37 ` Jason Merrill
2016-09-15 10:00 ` Rainer Orth
2016-09-15 12:23 ` Christophe Lyon
2016-09-15 20:09 ` Jason Merrill
2016-09-16 7:12 ` Rainer Orth
2016-09-16 8:15 ` Christophe Lyon
2016-09-16 9:14 ` Jonathan Wakely
2016-09-16 9:51 ` Marc Glisse
2016-09-16 11:12 ` Jonathan Wakely
2016-09-16 13:13 ` Jonathan Wakely
2016-09-16 13:17 ` Rainer Orth
2016-09-16 18:19 ` Jonathan Wakely [this message]
2016-09-12 14:15 ` Rainer Orth
2016-09-12 16:19 ` Jonathan Wakely
2016-09-12 18:57 ` Jason Merrill
2016-09-14 12:11 ` Rainer Orth
2016-09-08 11:00 ` Jonathan Wakely
2017-11-24 14:26 ` Marc Glisse
2017-11-29 21:23 ` Jason Merrill
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20160916180908.GQ17376@redhat.com \
--to=jwakely@redhat.com \
--cc=christophe.lyon@linaro.org \
--cc=gcc-patches@gcc.gnu.org \
--cc=jason@redhat.com \
--cc=libstdc++@gcc.gnu.org \
--cc=ro@CeBiTec.Uni-Bielefeld.DE \
--cc=schwab@linux-m68k.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).