This is the mail archive of the gdb@sourceware.org mailing list for the GDB 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: Python: should gdb.Value array indexing check bounds?


>>>>> "Paul" == Paul Koning <paulkoning@comcast.net> writes:

Paul> Currently, if a gdb.Value object corresponds to an array, array
Paul> indexing is done C-style: no bounds checking, just pointer
Paul> arithmetic.  That's somewhat unnatural to Python.  Should it do a
Paul> range check instead, and raise IndexError for out of range index
Paul> values?

I think it would be good if the bad cases could somehow be avoided.

Matt> I'd think no because of things like:
Matt> http://gcc.gnu.org/onlinedocs/gcc-4.1.2/gcc/Zero-Length.html
Matt> (which is possible with non-zero length arrays also).

Paul> I suppose that could be handled by making the check not apply in that
Paul> case.

I think there are other bad cases -- e.g., the classic C struct hack
uses an array with 1 element.

Paul> Or the bounds could be made writable?  Right now the bounds go
Paul> with the type, not the value; for them to be writable they would have
Paul> to go with the value.

This sounds like Jan's VLA patchset.

I'm not sure how rewriting the bounds would work in practice.
I guess you could just cast the array to a pointer today.

Tom


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