Summary: | [3.4 Regression] Wrong default allocator in ext/hash_map | ||
---|---|---|---|
Product: | gcc | Reporter: | Mattias Ellert <mattias.ellert> |
Component: | libstdc++ | Assignee: | Paolo Carlini <paolo.carlini> |
Status: | RESOLVED FIXED | ||
Severity: | normal | CC: | gcc-bugs |
Priority: | P2 | ||
Version: | 3.4.4 | ||
Target Milestone: | 3.4.5 | ||
Host: | Target: | ||
Build: | Known to work: | 3.3.3 4.0.0 4.1.0 | |
Known to fail: | 3.4.0 | Last reconfirmed: | |
Attachments: |
The testcase that exemplifies the error
Patch against the gcc 3.4.4 STL headers |
Description
Mattias Ellert
2005-08-23 11:58:28 UTC
Created attachment 9563 [details]
The testcase that exemplifies the error
It fails with gcc 3.4.4 but works correctly with gcc 3.3.4
Created attachment 9564 [details]
Patch against the gcc 3.4.4 STL headers
With this patch applied to gcc 3.4.4 it compiles correctly with this compiler
too.
This works in both on the mainlline and in 4.0.0. Also the fix is not really a correct fix as this area was not what changed between 3.4.0 and 4.0.0. I agree that something much more subtle is going on, maybe even a C++ front-end bug in 3_4-branch. Notice that hash_map<>::allocator_type is typedef-ed as _Ht::allocator_type, which, in turn (see the hashtable class in hashtable.h) is, correctly, an allocator of pair<const _Key, _Tp>. Likewise for hash_map<>::value_type. More analysis is required... I forgot to mention that the preprocessed source from 4.1.0 compiles just fine with the 3.4.0 compiler. (In reply to comment #5) I find this very hard to believe: the ext/ headers are basically frozen. (In reply to comment #6) Ok, Andrew is right, just double checked. A big mistery... (In reply to comment #7) > A big mistery... Actually, in 3_4-branch memory allocation in class hashtable was rather different, forgot about that. The bug is there. Oh and the preprocessed created with 3.4.0 gives the same error on the mainline too. It looks like the problem has been fixed in revision 1.6 of hashtable.h. Mattias, can you experiment a bit with just changing in class hashtable: typedef _Alloc allocator_type; to typedef typename _Alloc::template rebind<value_type>::other allocator_type; (likely, you have available code using hash_map much more complex than I do) (In reply to comment #10) Your proposed alternative patch works for me. Both for the testcase in this bug report and when I compile the code I was building when I found the bug. (In reply to comment #11) Thanks a lot. I think adding a proper rebind is the right way to fix the problem, already used in mainline and 4_0-branch, by the way. Fixed with: 2005-08-29 Paolo Carlini <pcarlini@suse.de> PR libstdc++/23528 Port from HEAD/4_0-branch: 2004-07-28 Matt Austern <austern@apple.com> * include/ext/hashtable.h: Use rebind so that allocator_type has correct type for a container's allocator. * testsuite/ext/23528.cc: New. |