[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Bug-gsl] array, vector indices out-of-bounds in "linalg/bidiag.c"
From: |
Andrew W. Steiner |
Subject: |
Re: [Bug-gsl] array, vector indices out-of-bounds in "linalg/bidiag.c" |
Date: |
Sun, 20 Apr 2008 21:22:02 -0400 |
In case it helps, see
http://www.gnu.org/software/gsl/design/gsl-design.html#SEC31
for why the loop is constructed that way.
On Sun, Apr 20, 2008 at 3:58 AM, Julian Seward <address@hidden> wrote:
>
> > for (j = N; j > 0 && j--;)
>
> This is an extremely strange for-loop header, and I wonder if
> it is what the author(s) really intended. I _think_ it might
> be equivalent to
>
> for (j = N; j > 0 && j != 0; /*no step action*/) {
> j--;
> /* now the rest of the loop body */
> }
> j--; /* because the condition is consulted 1 more time than the
> loop body runs */
>
> so there isn't necessarily an overrun at j = N.
>
> I wonder if it would not be cleaner to use a standard idiom:
>
> for (j = N-1; j >= 0; j--)
>
> IMO even a C language lawyer would have a hard time figuring out
> what the exact behaviour is here, which doesn't bode well for
> end-user understanding of the code.
>
> You might want to try Valgrind's Memcheck tool to see if there
> are in fact any overruns happening.
>
>
>
> J
>
>
> _______________________________________________
> Bug-gsl mailing list
> address@hidden
> http://lists.gnu.org/mailman/listinfo/bug-gsl
>
- [Bug-gsl] array, vector indices out-of-bounds in "linalg/bidiag.c", Kort Travis, 2008/04/20
- Re: [Bug-gsl] array, vector indices out-of-bounds in "linalg/bidiag.c", Julian Seward, 2008/04/20
- Re: [Bug-gsl] array, vector indices out-of-bounds in "linalg/bidiag.c",
Andrew W. Steiner <=
- Re: [Bug-gsl] array, vector indices out-of-bounds in "linalg/bidiag.c", Julian Seward, 2008/04/22
- Re: [Bug-gsl] array, vector indices out-of-bounds in "linalg/bidiag.c", Brian Gough, 2008/04/23
- Re: [Bug-gsl] array, vector indices out-of-bounds in "linalg/bidiag.c", Gerard Jungman, 2008/04/23
- Re: [Bug-gsl] array, vector indices out-of-bounds in "linalg/bidiag.c", Julian Seward, 2008/04/24