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: debug/vector anomalous behaviour


On Sat, 10 May 2008, Paolo Carlini wrote:
The latter behavior, by itself, seems right to me: in pedantic mode, when the correctness according to the strict letter of standard counts, debug mode is indeed able to figure out that no reallocation is happening and the code is safe.

Exactly. My note was referred to the above snippet of code where the pedantic behaviour seems to be safe whereas the non-pedantic behaviour isn't so.

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.

Stefano Soffia
Applied Formal Methods Laboratory
Department of Mathematics, University of Parma, Italy
http://www.cs.unipr.it/afmlab/


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