Help needed with suspicious code in Sparse.cc

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Help needed with suspicious code in Sparse.cc

John W. Eaton
Administrator
Clang is generating the following warning:

   Sparse.cc:136:18: warning: explicitly assigning value of variable of
type 'octave_idx_type' (aka 'int') to itself [-Wself-assign]
     for (i = i; i < u; i++)
          ~ ^ ~

The same thing appears on line 946 in that file.

It looks to me as if the code is correct, but the warning could be
avoided if the loop were written as

   for (; i < u; i++)

Could someone who understands the sparse matrix code comment?

Thanks,

jwe

Reply | Threaded
Open this post in threaded view
|

Re: Help needed with suspicious code in Sparse.cc

Rik-4
On 02/24/2016 09:43 AM, [hidden email] wrote:
Subject:
Help needed with suspicious code in Sparse.cc
From:
"John W. Eaton" [hidden email]
Date:
02/24/2016 09:19 AM
To:
Octave Maintainers List [hidden email]
CC:
[hidden email]
List-Post:
[hidden email]
Content-Transfer-Encoding:
7bit
Precedence:
list
MIME-Version:
1.0
Message-ID:
[hidden email]
Content-Type:
text/plain; charset=utf-8; format=flowed
Message:
2

Clang is generating the following warning:

  Sparse.cc:136:18: warning: explicitly assigning value of variable of type 'octave_idx_type' (aka 'int') to itself [-Wself-assign]
    for (i = i; i < u; i++)
         ~ ^ ~

The same thing appears on line 946 in that file.

It looks to me as if the code is correct, but the warning could be avoided if the loop were written as

  for (; i < u; i++)

Could someone who understands the sparse matrix code comment?

Yes, that looks correct to me.

I made the proposed change and also instrumented the code with a printf statement;  I do get hits when running 'make check' and the regression tests pass so it seems safe.

--Rik
Reply | Threaded
Open this post in threaded view
|

Re: Help needed with suspicious code in Sparse.cc

John W. Eaton
Administrator
On 02/24/2016 01:07 PM, Rik wrote:

> Yes, that looks correct to me.
>
> I made the proposed change and also instrumented the code with a printf
> statement;  I do get hits when running 'make check' and the regression
> tests pass so it seems safe.

Thanks, I checked in a changeset for this.

jwe