|
|
Subscribe / Log in / New account

GCC 4.8.1 released

GCC 4.8.1 released

Posted Jun 5, 2013 1:38 UTC (Wed) by luto (guest, #39314)
In reply to: GCC 4.8.1 released by jwakely
Parent article: GCC 4.8.1 released

Mainly paranoia. It's easy enough to do:

TrivialAllocator a;
std::map<T, U, TrivialAllocator> m(a);

and then accidentally copy or move m, causing memory corruption. (Also, I never really trusted non-allocator-aware containers to acutally copy a as opposed to doing a rebind and default-constructing a new one, since pre-C++11 allocators were pretty much intended to be stateless AFAICT.)


to post comments

GCC 4.8.1 released

Posted Jun 5, 2013 10:07 UTC (Wed) by jwakely (subscriber, #60262) [Link]

> I never really trusted non-allocator-aware containers to acutally copy a as opposed to doing a rebind and default-constructing a new one,

But GCC's containers have *always* got that right, that can be verified easily if you cared to.

> since pre-C++11 allocators were pretty much intended to be stateless AFAICT.

No, containers were allowed to assume allocators were stateless, but the intention was to support stateful ones, the standard specifically said so: "Implementors are encouraged to supply libraries that can accept allocators that encapsulate more general memory models and that support non-equal instances." And indeed most implementations had some support for stateful allocators.

I suspect what you want doesn't depend on the allocator-aware requirements, so if you'd wanted it that badly for years you could have done it.

I also suspect the many hours I've spent implementing the allocator-aware requirements have been a massive waste of my time :-\


Copyright © 2025, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds