Uploaded image for project: 'C++ Standard Library'
  1. C++ Standard Library
  2. STDCXX-744

error calling std::allocator::allocate() from user-defined allocator

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Major
    • Resolution: Unresolved
    • 4.2.0, 4.2.1
    • 4.2.2
    • 20. General Utilities
    • None
    • gcc 4.1.2

    • Compiler Error

    Description

      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.

      $ 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
      

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              sebor Martin Sebor
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

                Created:
                Updated:

                Time Tracking

                  Estimated:
                  Original Estimate - 2h
                  2h
                  Remaining:
                  Remaining Estimate - 2h
                  2h
                  Logged:
                  Time Spent - Not Specified
                  Not Specified