public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libstdc++/56437] New: basic_string assumes that allocators are default-constructible
@ 2013-02-24 23:40 tneumann at pi3 dot informatik.uni-mannheim.de
2013-02-25 0:09 ` [Bug libstdc++/56437] " redi at gcc dot gnu.org
` (5 more replies)
0 siblings, 6 replies; 7+ messages in thread
From: tneumann at pi3 dot informatik.uni-mannheim.de @ 2013-02-24 23:40 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56437
Bug #: 56437
Summary: basic_string assumes that allocators are
default-constructible
Classification: Unclassified
Product: gcc
Version: 4.8.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: libstdc++
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: tneumann@pi3.informatik.uni-mannheim.de
Created attachment 29531
--> http://gcc.gnu.org/bugzilla/attachment.cgi?id=29531
example
The empty-string optimization of basic_string assumes that allocators are
default constructible. While this used to be the case in C++98, it is no longer
true in C++11, as now allocators are allowed to have state.
Consider the attached example program. Compiling with
g++ -std=c++11 -c t.cpp
produces an error message, even though it should compile fine. The problem is
the the "_S_construct" calls "_Alloc()", which does not exist.
Note that the C++11 standard does not require default constructors. (Section
17.6.3.5, Table 28). In particular, the SimpleAllocator example from Section
17.6.3.5 would trigger the same bug, too.
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug libstdc++/56437] basic_string assumes that allocators are default-constructible
2013-02-24 23:40 [Bug libstdc++/56437] New: basic_string assumes that allocators are default-constructible tneumann at pi3 dot informatik.uni-mannheim.de
@ 2013-02-25 0:09 ` redi at gcc dot gnu.org
2013-02-25 0:12 ` redi at gcc dot gnu.org
` (4 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: redi at gcc dot gnu.org @ 2013-02-25 0:09 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56437
--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> 2013-02-25 00:08:35 UTC ---
This is hardly the only C++11 allocator requirement missing from std::string,
ALL of the new requirements are missing, and unlikely to be implemented until
we switch to a non-COW string implementation.
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug libstdc++/56437] basic_string assumes that allocators are default-constructible
2013-02-24 23:40 [Bug libstdc++/56437] New: basic_string assumes that allocators are default-constructible tneumann at pi3 dot informatik.uni-mannheim.de
2013-02-25 0:09 ` [Bug libstdc++/56437] " redi at gcc dot gnu.org
@ 2013-02-25 0:12 ` redi at gcc dot gnu.org
2013-02-25 6:32 ` tneumann at pi3 dot informatik.uni-mannheim.de
` (3 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: redi at gcc dot gnu.org @ 2013-02-25 0:12 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56437
--- Comment #2 from Jonathan Wakely <redi at gcc dot gnu.org> 2013-02-25 00:11:16 UTC ---
C++11 allocators are not required to define any of these:
typedef T* pointer;
typedef const T* const_pointer;
typedef T& reference;
typedef const T& const_reference;
typedef unsigned size_type;
typedef int difference_type;
template <class U> struct rebind { typedef MyAllocator<U> other; };
But if your allocator fails to define any of them then std::string (and some of
the other containers) will fail to compile. This is a known issue.
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug libstdc++/56437] basic_string assumes that allocators are default-constructible
2013-02-24 23:40 [Bug libstdc++/56437] New: basic_string assumes that allocators are default-constructible tneumann at pi3 dot informatik.uni-mannheim.de
2013-02-25 0:09 ` [Bug libstdc++/56437] " redi at gcc dot gnu.org
2013-02-25 0:12 ` redi at gcc dot gnu.org
@ 2013-02-25 6:32 ` tneumann at pi3 dot informatik.uni-mannheim.de
2013-02-25 11:18 ` paolo.carlini at oracle dot com
` (2 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: tneumann at pi3 dot informatik.uni-mannheim.de @ 2013-02-25 6:32 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56437
--- Comment #3 from Thomas Neumann <tneumann at pi3 dot informatik.uni-mannheim.de> 2013-02-25 06:31:43 UTC ---
(In reply to comment #1)
> This is hardly the only C++11 allocator requirement missing from std::string,
> ALL of the new requirements are missing, and unlikely to be implemented until
> we switch to a non-COW string implementation.
Well, but this would be an allocator requirement that is easy to fix. There are
only three places with "_Alloc()" in basic_string.tcc, and only two would have
to be fixed as far as I can see it.
I am not sure yet why the code even tries to construct the allocator, but if
necessary we could use is_default_constructible to figure out of the
constructor is available. I could try to produce a patch myself if you prefer.
But as of new basic_string is quite unusable with stateful allocators.
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug libstdc++/56437] basic_string assumes that allocators are default-constructible
2013-02-24 23:40 [Bug libstdc++/56437] New: basic_string assumes that allocators are default-constructible tneumann at pi3 dot informatik.uni-mannheim.de
` (2 preceding siblings ...)
2013-02-25 6:32 ` tneumann at pi3 dot informatik.uni-mannheim.de
@ 2013-02-25 11:18 ` paolo.carlini at oracle dot com
2014-09-19 11:00 ` redi at gcc dot gnu.org
2014-12-22 13:50 ` redi at gcc dot gnu.org
5 siblings, 0 replies; 7+ messages in thread
From: paolo.carlini at oracle dot com @ 2013-02-25 11:18 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56437
--- Comment #4 from Paolo Carlini <paolo.carlini at oracle dot com> 2013-02-25 11:17:30 UTC ---
Note that all such changes should be applied to ext/vstring (which will become
basic_string in 4.9) not to basic_string. By now the latter is frozen, modulo
serious regressions.
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug libstdc++/56437] basic_string assumes that allocators are default-constructible
2013-02-24 23:40 [Bug libstdc++/56437] New: basic_string assumes that allocators are default-constructible tneumann at pi3 dot informatik.uni-mannheim.de
` (3 preceding siblings ...)
2013-02-25 11:18 ` paolo.carlini at oracle dot com
@ 2014-09-19 11:00 ` redi at gcc dot gnu.org
2014-12-22 13:50 ` redi at gcc dot gnu.org
5 siblings, 0 replies; 7+ messages in thread
From: redi at gcc dot gnu.org @ 2014-09-19 11:00 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=56437
Jonathan Wakely <redi at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |ASSIGNED
Last reconfirmed| |2014-09-19
Assignee|unassigned at gcc dot gnu.org |redi at gcc dot gnu.org
Target Milestone|--- |5.0
Ever confirmed|0 |1
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug libstdc++/56437] basic_string assumes that allocators are default-constructible
2013-02-24 23:40 [Bug libstdc++/56437] New: basic_string assumes that allocators are default-constructible tneumann at pi3 dot informatik.uni-mannheim.de
` (4 preceding siblings ...)
2014-09-19 11:00 ` redi at gcc dot gnu.org
@ 2014-12-22 13:50 ` redi at gcc dot gnu.org
5 siblings, 0 replies; 7+ messages in thread
From: redi at gcc dot gnu.org @ 2014-12-22 13:50 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=56437
Jonathan Wakely <redi at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|ASSIGNED |RESOLVED
Resolution|--- |FIXED
--- Comment #5 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Fixed for GCC 5 (when using the new string ABI)
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2014-12-22 13:50 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-02-24 23:40 [Bug libstdc++/56437] New: basic_string assumes that allocators are default-constructible tneumann at pi3 dot informatik.uni-mannheim.de
2013-02-25 0:09 ` [Bug libstdc++/56437] " redi at gcc dot gnu.org
2013-02-25 0:12 ` redi at gcc dot gnu.org
2013-02-25 6:32 ` tneumann at pi3 dot informatik.uni-mannheim.de
2013-02-25 11:18 ` paolo.carlini at oracle dot com
2014-09-19 11:00 ` redi at gcc dot gnu.org
2014-12-22 13:50 ` redi at gcc dot gnu.org
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).