[
https://issues.apache.org/jira/browse/STDCXX-744?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12614521#action_12614521
]
Martin Sebor commented on STDCXX-744:
-------------------------------------
This is partly because our {{vector}} derives from its {{Allocator}} argument
to take advantage of the [EBO|http://www.cantrip.org/emptyopt.html]. The direct
derivation has turned out to be a mistake but fixing it has to be done with
care so as not to break the ABI. The fix is to make the Allocator a base class
of a member type containing a non-empty member object such as the size of the
{{vector}} instead.
> error calling std::allocator::allocate() from user-defined allocator
> --------------------------------------------------------------------
>
> Key: STDCXX-744
> URL: https://issues.apache.org/jira/browse/STDCXX-744
> Project: C++ Standard Library
> Issue Type: Bug
> Components: 20. General Utilities
> Affects Versions: 4.2.0, 4.2.1
> Environment: gcc 4.1.2
> Reporter: Martin Sebor
> Fix For: 4.2.2
>
> Original Estimate: 2h
> Remaining Estimate: 2h
>
> The program below reduced from Plum Hall test case
> {{lvs07a/t237.dir/_23252Y11.cpp}} fails to compile with both the head of
> trunk and stdcxx 4.2.0. It compiles fine with gcc 4.1.2.
> {noformat}
> $ cat t.cpp && make t
> #include <memory>
> #include <vector>
> template <class T>
> struct Allocator: std::allocator<T> {
> T* allocate (unsigned n, const T *p) {
> return std::allocator<T>::allocate (n, p);
> }
> };
> int main () {
> std::vector<int, Allocator<int> > v (2, 3);
> }
> gcc -c -I$TOPDIRinclude/ansi -D_RWSTDDEBUG -I$TOPDIRinclude
> -I/build/sebor/stdcxx-gcc-4.1.2-11S-LVS/include -I$TOPDIRinclude/ansi
> -I/build/sebor/PlumHall/lvs07a/conform -I/build/sebor/PlumHall/lvs07a/dst.3
> -pedantic -nostdinc++ -g -W -Wall -Wcast-qual -Winline -Wshadow
> -Wwrite-strings -Wno-long-long -Wcast-align t.cpp
> $TOPDIRinclude/vector.cc: In member function 'void std::vector<_TypeT,
> _Allocator>::_C_realloc(typename _Allocator::size_type) [with _TypeT = int,
> _Allocator = Allocator<int>]':
> $TOPDIRinclude/vector:501: instantiated from 'void std::vector<_TypeT,
> _Allocator>::reserve(typename _Allocator::size_type) [with _TypeT = int, _A
> llocator = Allocator<int>]'
> $TOPDIRinclude/vector.cc:219: instantiated from 'void std::vector<_TypeT,
> _Allocator>::_C_insert_n(const _rw::__rw_debug_iter<std::vector<_TypeT,
> _Allocator>, typename _Allocator::pointer, typename _Allocator::pointer>&,
> typename _Allocator::size_type, typename _Allocator::const_reference) [with
> _TypeT = int, _Allocator = Allocator<int>]'
> $TOPDIRinclude/vector:301: instantiated from 'void std::vector<_TypeT,
> _Allocator>::insert(__rw::__rw_debug_iter<std::vector<_TypeT, _Allocator>,
> typename _Allocator::pointer, typename _Allocator::pointer>, typename
> _Allocator::size_type, typename _Allocator::const_reference) [with _TypeT =
> int, _Allocator = Allocator<int>]'
> $TOPDIRinclude/vector.cc:152: instantiated from 'void std::vector<_TypeT,
> _Allocator>::_C_assign_n(typename _Allocator::size_type, typename
> _Allocator::const_reference) [with _TypeT = int, _Allocator = Allocator<int>]'
> $TOPDIRinclude/vector:362: instantiated from 'void std::vector<_TypeT,
> _Allocator>::_C_assign(_IntType, _IntType, int) [with _IntType = int, _Type
> T = int, _Allocator = Allocator<int>]'
> $TOPDIRinclude/vector:194: instantiated from 'void std::vector<_TypeT,
> _Allocator>::assign(_InputIter, _InputIter) [with _InputIter = int, _TypeT =
> int, _Allocator = Allocator<int>]'
> $TOPDIRinclude/vector:173: instantiated from 'std::vector<_TypeT,
> _Allocator>::vector(_InputIter, _InputIter, const _Allocator&) [with
> _InputIter = int, _TypeT = int, _Allocator = Allocator<int>]'
> t.cpp:12: instantiated from here
> $TOPDIRinclude/vector.cc:85: error: no matching function for call to
> 'std::vector<int, Allocator<int> >::allocate(long unsigned int&,
> std::vector<int, Allocator<int> >* const)'
> t.cpp:6: note: candidates are: T* Allocator<T>::allocate(unsigned int, const
> T*) [with T = int]
> make: *** [t.o] Error 1
> {noformat}
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.