This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [Patch] stl_vector.h


Dhruv Matani wrote:

Hello,
	Here is the patch for the bug that I had mentioned earlier on.

I ahve also attached a test-case for replicating the bug.

This bug actually helped me fix a totally unralated error in some other
part of my program!


I don't think we have a bug, neither I think your testcase is correct. Why you have an assert( n != 0) in the allocator? According to the standard, the return value of allocate when n == 0 is unspecified, indeed, but is anyway perfectly legal to call allocate with n == 0. What happens then in std::vector is that all of the _M_impl pointers become equal and the various algorithms do not iterate at all, no problem. In fact all of our allocators + vector accept std::vector vv(0, 1) and are able to deal with it correctly subsequently. To summarize, I think that the testcase (the allocator part of it) is wrong, not our vector class.

Paolo.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]