Weird?

A

A

while compiling my code I get the following message:

matfunoperable.cpp: In member function ?virtual void
matfunoperable::qrdelete(gsl_matrix*, gsl_matrix*, size_t, char)?:
matfunoperable.cpp:32: warning: suggest parentheses around assignment
used as truth value
matfunoperable.cpp:35: warning: suggest parentheses around assignment
used as truth value



Code snippet that contains lines 32 and 35:

32 for (size_t iter = 0; iter = j-2; iter++){
33
gsl_vector_memcpy(&gsl_matrix_column(R_new,iter).vector,&gsl_matrix_column(R,iter).vector);
34 }
35 for (size_t iter = j-1; iter = n-1; iter++){
36
gsl_vector_memcpy(&gsl_matrix_column(R_new,iter).vector,&gsl_matrix_column(R,(iter+1)).vector);
37 }


prototype of the function (in the .h file) in which the above snippet
is contained is:

virtual void qrdelete(gsl_matrix *Q_new, gsl_matrix *R_new, const
size_t j, const char orient);


The executable is formed. However when I run the executable, none of
the instructions in main() are executed. Can anyone throw some light on
what is happening here?

Thanks,
A
 
I

Ian Collins

A said:
while compiling my code I get the following message:

matfunoperable.cpp: In member function ?virtual void
matfunoperable::qrdelete(gsl_matrix*, gsl_matrix*, size_t, char)?:
matfunoperable.cpp:32: warning: suggest parentheses around assignment
used as truth value
matfunoperable.cpp:35: warning: suggest parentheses around assignment
used as truth value



Code snippet that contains lines 32 and 35:

32 for (size_t iter = 0; iter = j-2; iter++){

Common bug which your compiler is kind enough to point out - you are
using assignment (=) rather than equality (==).
 
N

Noah Roberts

A said:
while compiling my code I get the following message:

matfunoperable.cpp: In member function ?virtual void
matfunoperable::qrdelete(gsl_matrix*, gsl_matrix*, size_t, char)?:
matfunoperable.cpp:32: warning: suggest parentheses around assignment
used as truth value
matfunoperable.cpp:35: warning: suggest parentheses around assignment
used as truth value



Code snippet that contains lines 32 and 35:

32 for (size_t iter = 0; iter = j-2; iter++){
The executable is formed. However when I run the executable, none of
the instructions in main() are executed. Can anyone throw some light on
what is happening here?

You're compiler is giving you a pretty good idea. Is it really your
intention to assign the value of j - 2 to iter and then test to make
sure the result is not 0?

What occurs is actually the best that could happen...other option is
infinite loop.
 
I

Ian Collins

Ian said:
Common bug which your compiler is kind enough to point out - you are
using assignment (=) rather than equality (==).
Or whatever comparison operator you intended.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,968
Messages
2,570,150
Members
46,697
Latest member
AugustNabo

Latest Threads

Top