This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC 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][google/integration] Add lightweight checks to vector::begin et. al. (issue4973065)


On 6 September 2011 19:01, Paul Pluzhnikov wrote:
>
>> But this is something to discuss with libstdc++ (CC'd).
>
> Sure. If the "parallel" debug mode is more tenable now, I am all for it.

I don't think anything has changed.  I'm not excited by the idea of
another debug mode, especially not this patch, which would never get
into mainline.

It is always valid to call vector::begin(), it's 'noexcept' so the
patch will cause immediate calls to std::terminate, so why throw
instead of just aborting?  Why is __valid not named consistently with
the v3 naming style?


What's a dangling vector anyway?  One that has been moved from?


> To give some context, in a large code base (> 1e6 lines of C++ code),
> the checks added in this patch found 20 bugs.
>
> Most (though not all) of these bugs could also have been found with Valgrind
> and (probably) with _GLIBCXX_DEBUG, but the runtime cost of running such
> heavy-weight checks over the entire code base is prohibitive.

You can do:

#ifdef MY_DEBUG_FLAG
#include <debug/vector>
namespace v = __gnu_debug;
#else
#include <vector>
namespace v = std;
#

Then use v::vector in specific places to only enable the checks in some places.


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