|
[bug-gsl] Re: array, vector indices out-of-bounds in "linalg/bidiag.c" (2008-04-23)
|
From: |
Gerard Jungman <jungman@........> |
|
Subject: |
Re: array, vector indices out-of-bounds in "linalg/bidiag.c" |
|
Date: |
Wed, 23 Apr 2008 15:19:55 -0600 |
|
To: |
Brian Gough <bjg@gnu.org> |
|
Cc: |
bug-gsl@gnu.org |
On Wed, 2008-04-23 at 15:14 +0100, Brian Gough wrote:
> I've played with a few variations and found that the alternative
>
> for (i = N; i-- > 0;)
Bah. I would just use the simple version he suggests
> > for (i = 0; i < N; i++) { j = N - i; ... }
The extra variable is perfectly reasonable.
> I never really liked code that depends on the distinction between --i
> and i--, being burned a few times by subtle bugs from not noticing the
> wrong one being used, hence the tendency to write things like i>0 &&
> i--.
I agree. The simple version is the best though.
--
G. Jungman
| |