Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Some warnings compiling LAPACKE with gcc #777

Closed
jgpallero opened this issue Jan 9, 2023 · 2 comments
Closed

Some warnings compiling LAPACKE with gcc #777

jgpallero opened this issue Jan 9, 2023 · 2 comments

Comments

@jgpallero
Copy link
Contributor

I've compiled Lapack 3.11.0 in Debian with gcc 12.2.0. All works well, but some warnings have been appeared compiling LAPACKE. There are not any serious, but I paste them here:

gcc -O3 -Wall -I../include -c -o lapacke_zlarfb.o lapacke_zlarfb.c
lapacke_zlarfb.c: In function ‘LAPACKE_zlarfb’:
lapacke_zlarfb.c:63:22: warning: suggest parentheses around ‘&&’ within ‘||’ [-Wparentheses]
   63 |         if( !forward && ( col && k > nrows_v ) || ( !col && k > ncols_v )) {
      |             ~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
gcc -O3 -Wall -I../include -c -o lapacke_zlarfb_work.o lapacke_zlarfb_work.c
lapacke_zlarfb_work.c: In function ‘LAPACKE_zlarfb_work’:
lapacke_zlarfb_work.c:84:22: warning: suggest parentheses around ‘&&’ within ‘||’ [-Wparentheses]
   84 |         if( !forward && ( col && k > nrows_v ) || ( !col && k > ncols_v )) {
      |             ~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
gcc -O3 -Wall -I../include -c -o lapacke_dlarfb.o lapacke_dlarfb.c
lapacke_dlarfb.c: In function ‘LAPACKE_dlarfb’:
lapacke_dlarfb.c:62:22: warning: suggest parentheses around ‘&&’ within ‘||’ [-Wparentheses]
   62 |         if( !forward && ( col && k > nrows_v ) || ( !col && k > ncols_v )) {
      |             ~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
gcc -O3 -Wall -I../include -c -o lapacke_dlarfb_work.o lapacke_dlarfb_work.c
lapacke_dlarfb_work.c: In function ‘LAPACKE_dlarfb_work’:
lapacke_dlarfb_work.c:83:22: warning: suggest parentheses around ‘&&’ within ‘||’ [-Wparentheses]
   83 |         if( !forward && ( col && k > nrows_v ) || ( !col && k > ncols_v )) {
      |             ~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
gcc -O3 -Wall -I../include -c -o lapacke_clarfb.o lapacke_clarfb.c
lapacke_clarfb.c: In function ‘LAPACKE_clarfb’:
lapacke_clarfb.c:63:22: warning: suggest parentheses around ‘&&’ within ‘||’ [-Wparentheses]
   63 |         if( !forward && ( col && k > nrows_v ) || ( !col && k > ncols_v )) {
      |             ~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
gcc -O3 -Wall -I../include -c -o lapacke_clarfb_work.o lapacke_clarfb_work.c
lapacke_clarfb_work.c: In function ‘LAPACKE_clarfb_work’:
lapacke_clarfb_work.c:84:22: warning: suggest parentheses around ‘&&’ within ‘||’ [-Wparentheses]
   84 |         if( !forward && ( col && k > nrows_v ) || ( !col && k > ncols_v )) {
      |             ~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
gcc -O3 -Wall -I../include -c -o lapacke_slarfb.o lapacke_slarfb.c
lapacke_slarfb.c: In function ‘LAPACKE_slarfb’:
lapacke_slarfb.c:62:22: warning: suggest parentheses around ‘&&’ within ‘||’ [-Wparentheses]
   62 |         if( !forward && ( col && k > nrows_v ) || ( !col && k > ncols_v )) {
      |             ~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
gcc -O3 -Wall -I../include -c -o lapacke_slarfb_work.o lapacke_slarfb_work.c
lapacke_slarfb_work.c: In function ‘LAPACKE_slarfb_work’:
lapacke_slarfb_work.c:83:22: warning: suggest parentheses around ‘&&’ within ‘||’ [-Wparentheses]
   83 |         if( !forward && ( col && k > nrows_v ) || ( !col && k > ncols_v )) {
      |             ~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
@langou
Copy link
Contributor

langou commented Jan 13, 2023

Hi @jgpallero,

thanks for the comment.

&& has a higher order of precedence in C than ||, so

a && b || c

is same as

(a && b ) || c

I agree with gcc though that it would be good to have "parentheses around && within ||". (And it would also have the added benefit to remove the gcc warning.)

This issue was already mentioned in #742 .

@jgpallero : can you propose a PR?

Julien.

@langou
Copy link
Contributor

langou commented Jan 13, 2023

Sorry for the back and forth @jgpallero. I reviewed the comments posted by @ACSimon33 in #742 (comment)_

And I agree. We should remove the !forward test.

So the line of code

if( !forward && ( col && k > nrows_v ) || ( !col && k > ncols_v ))

should be changed to

if( ( col && k > nrows_v ) || ( !col && k > ncols_v ) )

in eight files.

I am sorry for the misdirection.

@jgpallero: Would you be willing to submit another PR?

@langou langou closed this as completed Jan 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants