[Bug libstdc++/19495] basic_string::_M_rep() can produce an unnaturally aligned pointer to _Rep

gdr at integrable-solutions dot net gcc-bugzilla@gcc.gnu.org
Wed Jan 19 16:02:00 GMT 2005


------- Additional Comments From gdr at integrable-solutions dot net  2005-01-19 16:02 -------
Subject: Re:  basic_string::_M_rep() can produce an unnaturally aligned pointer to _Rep

"pcarlini at suse dot de" <gcc-bugzilla@gcc.gnu.org> writes:

| Well, I can see that basic_string default allocator, std::allocator<CharT>
| according to the standard shall return memory only aligned as CharT requests,
| not more; whereas our implementation of std::allocator provides stronger
| alignment guarantees. But I can also see that the general requirements in
| the standard for allocators do *not* talk about alignment at all...

well, I don't think we can go very far with that stretch :-)

| Therefore, probably, it would be nice if basic_string could make use of
| memory only aligned as CharT wants, not more, but, AFAICS, this principle

Yes.  Basically, we need to have tha aligned attribute work correctly.

| is not present in the original design. I don't think we can implement it
| now, for 4.0, without changing the ABI. I think we should just document
| that for our current basic_string memory rerurned by the allocator should
| be maximally aligned (in some cases less aligned is ok, but details become
| tricky to spell out).

I rather we fix it.  Remember, this is more an optimization issue
than a semantics issue.  An optimization issue that had causes us
more trouble than benefits I believe.  I don't believe it is wise 
for us to go that path down putting more an more restrictions.
With people playing with fancy allocator around, it is likely that
we're going to have more and more of this issue popping up.

In some sense, I'm happy that C++ finally gives progremmers ways
to crontrol storage allocation.

-- Gaby


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19495



More information about the Gcc-bugs mailing list