On Tue, May 6, 2008 at 11:12 PM, Xavier Delacour
<[EMAIL PROTECTED]> wrote:
>  >  Indeed, I get a segfault at this point. When debugging, I see that
>  >  vector<T>::operator[] is really executed with an out-of-bound index.
>  >  And this really dereference and invalid memory location. If you look
>  >  into MSVC header you find something like:
>  >
>  >         reference operator[](size_type _Pos)
>  >                 {       // subscript mutable sequence
>  >                 return (*(_Myfirst + _Pos));
>  >                 }
>
>  Huh. Well, I wouldn't expect this to "dereference"  (_Myfirst + _Pos),
>  by which I mean "read the byte from memory" any more than I would
>  expect
>
>  char* p = (char*) 0;
>  char& r = *p;

Sorry, I was wrong in my previous analysis. In the sample code above,
I removed some parts, because I thought they were not related to the
problem. However, before the "return" statement, there is some code
that checks whether _Pos is a valid index within vector range.
This validation function produces a runtime error and makes the
program exits. So, in the end, it's not a dereferencing problem, but
a runtime error due to some bound-checking code.

Michael.

-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference 
Don't miss this year's exciting event. There's still time to save $100. 
Use priority code J8TL2D2. 
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
_______________________________________________
Octave-dev mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/octave-dev

Reply via email to