Marc Boyer <[EMAIL PROTECTED]> writes:
> is there a way to ask g++ to give the semantics of
> vector::at() (ie checking bounds) to vector::operator[]
> in some 'debug mode'.
For recent versions of g++ (3.4.0 and above), -D_GLIBCXX_DEBUG
finds this error (and many others):
$ cat junk.cc
#include <vector>
typedef std::vector<int> VI;
int main() {
VI vi; vi.push_back(1);
int x = vi[1]; // bug
}
$ /usr/local/gcc-3.4.6/bin/g++ -g junk.cc -D_GLIBCXX_DEBUG && ./a.out
/usr/local/gcc-3.4.6/include/c++/3.4.6/debug/vector:192:
error: attempt to subscript container with out-of-bounds index 1, but
container only holds 1 elements.
Objects involved in the operation:
sequence "this" @ 0x0xbfffdf90 {
type = N15__gnu_debug_def6vectorIiSaIiEEE;
}
Aborted (core dumped)
Cheers,
--
In order to understand recursion you must first understand recursion.
Remove /-nsp/ for email.
_______________________________________________
help-gplusplus mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/help-gplusplus