Opened 13 years ago

Closed 13 years ago

Last modified 13 years ago

#3536 closed Bugs (invalid)

ptr_map doesn't support incomplete type with view clone allocator

Reported by: olafvdspek@… Owned by: Thorsten Ottosen
Milestone: Boost 1.41.0 Component: ptr_container
Version: Boost 1.40.0 Severity: Problem
Keywords: Cc:

Description

#include <boost/ptr_container/ptr_map.hpp>

class C;

int main()
{
	boost::ptr_map<int, C, boost::view_clone_allocator> c;
	return 0;
}

boost\checked_delete.hpp(32) : error C2027: use of undefined type 'C'
        c:\documents and settings\internet\my documents\visual studio 2008\projects\test\test.cpp(3) : see declaration of 'C'
        boost\ptr_container\clone_allocator.hpp(56) : see reference to function template instantiation 'void boost::checked_delete<const T>(T *)' being compiled
        with
        [
            T=C
        ]
        boost\ptr_container\clone_allocator.hpp(74) : see reference to function template instantiation 'void boost::delete_clone<U>(const T *)' being compiled
        with
        [
            U=C,
            T=C
        ]
        boost\ptr_container\detail\reversible_ptr_container.hpp(126) : see reference to function template instantiation 'void boost::heap_clone_allocator::deallocate_clone<C>(const U *)' being compiled
        with
        [
            U=C
        ]
        boost\ptr_container\detail\reversible_ptr_container.hpp(119) : while compiling class template member function 'void boost::ptr_container_detail::reversible_ptr_container<Config,CloneAllocator>::null_clone_allocator<allow_null_values>::deallocate_clone(const C *)'
        with
        [
            Config=boost::ptr_container_detail::map_config<C,std::map<int,void *,boost::view_clone_allocator,std::allocator<std::pair<const int,void *>>>,true>,
            CloneAllocator=boost::heap_clone_allocator,
            allow_null_values=false
        ]
        boost\ptr_container\detail\reversible_ptr_container.hpp(276) : see reference to class template instantiation 'boost::ptr_container_detail::reversible_ptr_container<Config,CloneAllocator>::null_clone_allocator<allow_null_values>' being compiled
        with
        [
            Config=boost::ptr_container_detail::map_config<C,std::map<int,void *,boost::view_clone_allocator,std::allocator<std::pair<const int,void *>>>,true>,
            CloneAllocator=boost::heap_clone_allocator,
            allow_null_values=false
        ]
        boost\ptr_container\detail\reversible_ptr_container.hpp(275) : while compiling class template member function 'void boost::ptr_container_detail::reversible_ptr_container<Config,CloneAllocator>::null_policy_deallocate_clone(const C *)'
        with
        [
            Config=boost::ptr_container_detail::map_config<C,std::map<int,void *,boost::view_clone_allocator,std::allocator<std::pair<const int,void *>>>,true>,
            CloneAllocator=boost::heap_clone_allocator
        ]
        boost\ptr_container\detail\associative_ptr_container.hpp(34) : see reference to class template instantiation 'boost::ptr_container_detail::reversible_ptr_container<Config,CloneAllocator>' being compiled
        with
        [
            Config=boost::ptr_container_detail::map_config<C,std::map<int,void *,boost::view_clone_allocator,std::allocator<std::pair<const int,void *>>>,true>,
            CloneAllocator=boost::heap_clone_allocator
        ]
        boost\ptr_container\ptr_map_adapter.hpp(130) : see reference to class template instantiation 'boost::ptr_container_detail::associative_ptr_container<Config,CloneAllocator>' being compiled
        with
        [
            Config=boost::ptr_container_detail::map_config<C,std::map<int,void *,boost::view_clone_allocator,std::allocator<std::pair<const int,void *>>>,true>,
            CloneAllocator=boost::heap_clone_allocator
        ]
        boost\ptr_container\ptr_map_adapter.hpp(388) : see reference to class template instantiation 'boost::ptr_container_detail::ptr_map_adapter_base<T,VoidPtrMap,CloneAllocator,Ordered>' being compiled
        with
        [
            T=C,
            VoidPtrMap=std::map<int,void *,boost::view_clone_allocator,std::allocator<std::pair<const int,void *>>>,
            CloneAllocator=boost::heap_clone_allocator,
            Ordered=true
        ]
        boost\ptr_container\ptr_map.hpp(36) : see reference to class template instantiation 'boost::ptr_map_adapter<T,VoidPtrMap,CloneAllocator>' being compiled
        with
        [
            T=C,
            VoidPtrMap=std::map<int,void *,boost::view_clone_allocator,std::allocator<std::pair<const int,void *>>>,
            CloneAllocator=boost::heap_clone_allocator
        ]
        c:\documents and settings\internet\my documents\visual studio 2008\projects\test\test.cpp(7) : see reference to class template instantiation 'boost::ptr_map<Key,T,Compare>' being compiled
        with
        [
            Key=int,
            T=C,
            Compare=boost::view_clone_allocator
        ]
boost\checked_delete.hpp(32) : error C2118: negative subscript
boost\checked_delete.hpp(34) : warning C4150: deletion of pointer to incomplete type 'C'; no destructor called
        c:\documents and settings\internet\my documents\visual studio 2008\projects\test\test.cpp(3) : see declaration of 'C'

Change History (3)

comment:1 by Steven Watanabe, 13 years ago

Component: Noneptr_container
Owner: set to Thorsten Ottosen

comment:2 by Steven Watanabe, 13 years ago

Resolution: invalid
Status: newclosed

Check the template arguments for ptr_map.

    template
    < 
        class Key, 
        class T, 
        class Compare        = std::less<Key>, 
        class CloneAllocator = heap_clone_allocator,
        class Allocator      = std::allocator< std::pair<const Key,void*> >
    >
    class ptr_map;

You're passing view_clone_allocator as Compare instead of as CloneAllocator.

comment:3 by olafvdspek@…, 13 years ago

Oops, sorry, my mistake.

Note: See TracTickets for help on using tickets.