[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: |
Julian Seward |
Subject: |
Re: [Bug-gsl] array, vector indices out-of-bounds in "linalg/bidiag.c" |
Date: |
Thu, 24 Apr 2008 13:51:25 +0200 |
User-agent: |
KMail/1.9.5 |
On Wednesday 23 April 2008 16:14, Brian Gough wrote:
> > for (i = N; i > 0 && i--;) { ... }
>
> That part as written when I was translating a lot of code from fortran
Heh. I wondered if that was the cause.
> I've played with a few variations and found that the alternative
>
> for (i = N; i-- > 0;)
Seems better. Compared to "for (i = 0; i < N; i++) { j = N - i; ... }"
it requires one less register, so is perhaps a not-bad tradeoff
between legibility and performance.
A kind-of related comment, fwiw: I've spent quite some time looking at
the code generated by gcc these past couple of years. And by and large
it seems to me that it produces the best code when the source is written
in the simplest possible, textbook style. Trying to "help it" by
doing weird low level coding tricks often makes things worse.
J
- [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, 2008/04/20
- 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 <=