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 22:58, Paul Pluzhnikov wrote:
> On Tue, Sep 6, 2011 at 2:51 PM, Jonathan Wakely <jwakely.gcc@gmail.com> wrote:
>
>> I don't mean for vector::begin and the other functions in that patch,
>> I mean in general for member functions of any type. There are plenty
>> of functions that wouldn't crash when called through a null pointer.
>> But even std:vector has member functions like that, such as max_size.
>
> Right. (We might tweak the compiler to automagically insert that assert
> in non-omitimized builds ;-)

Heh :-)

Have you considered a compiler option to make 'delete v' zero out the
pointer, so that any following use of it gives an immediate segfault?
That would be conforming (the value of delete's operand is unspecified
after the operation), but would only help if the same pointer is used,
rather than another object with the same value.  I don't know of any
compiler that does that, but have wondered if it would be useful for
debugging some cases.


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