This is the mail archive of the 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: debug/vector anomalous behaviour

On Sat, May 10, 2008 at 7:21 AM, Stefano Soffia <> wrote:
> On Sat, 10 May 2008, Paolo Carlini wrote:
>> However, I'm puzzled by the default, which uses the _M_guaranteed_capacity
>> idea, trying to flag potentially dangerous situations. Now that I look a bit
>> into it, frankly I'm not sure it's worth such kind of false positives...
>> Maybe Doug (the author of these bits, a long time ago, if I remember
>> correctly...), wants to clarify the rationale.
> I have spoken about this with my colleagues Enea Zaffanella and Roberto
> Bagnara and our guess is that the intended meaning for the pedantic mode is
> to provide the user with the minimal capacity() necessary satisfy the
> requirements of the C++ Standard (for example, this would mean that when a
> push_back() requires a reallocation, instead of doubling the current
> capacity(), the capacity is increased only by 1.)
> While the non-pedantic behaviour simply provides the capacity of the
> underlying implementation, allowing the user to make assumptions about
> implementation-defined aspects of the standard.

Yes, this was exactly my intent. The standard doesn't say how the
capacity rows, so _M_guaranteed_capacity mimics the slowest-growing
vector possible while this->capacity() is how libstdc++ actually grows
the vector. It's under the pedantic mode because nearly every standard
library implementation grows a vector the same way.

  - Doug

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