Discussion:
[eigen] Logical expression with BLAS version error?
M A
2018-12-03 02:11:37 UTC
Permalink
I'm testing out some code using BLAS from Eigen as described in the dox. I
get the below warning when compiling (and still the correct answer; it's
just a warning).

warning:
& has lower precedence than ==; == will be evaluated first
[-Wparentheses]
expanded from macro 'EIGEN_BLAS_RANKUPDATE_SPECIALIZE'
if ( lhs==rhs && ((UpLo&(Lower|Upper)==UpLo)) ) { \

This occurs in line 55 of GeneralMatrixMatrixTriangular_BLAS.h.

I was trying to unpack that if statement and found myself confused and
wondering if one of those closing parentheses is misplaced. Currently the
double parentheses don't seem to be doing anything beyond what a single
parentheses would do, suggesting a possible typo. As it's written the
(Lower|Upper) == UpLo results in a bool which is bitwise anded with the int
UpLo. I may be being pedantic, but this doesn't seem technically safe as, I
believe, the bitwise representation of true and false are not specified in
the c++ standard. Am I missing something or is this an error in the code?


Mark
Gael Guennebaud
2018-12-03 12:04:17 UTC
Permalink
Hi,

this has been fixed a while ago in changeset ea373d516b5c, the line is now:

if ( lhs==rhs && ((UpLo&(Lower|Upper))==UpLo) ) { \

gael
Post by M A
I'm testing out some code using BLAS from Eigen as described in the dox. I
get the below warning when compiling (and still the correct answer; it's
just a warning).
& has lower precedence than ==; == will be evaluated first
[-Wparentheses]
expanded from macro 'EIGEN_BLAS_RANKUPDATE_SPECIALIZE'
if ( lhs==rhs && ((UpLo&(Lower|Upper)==UpLo)) ) { \
This occurs in line 55 of GeneralMatrixMatrixTriangular_BLAS.h.
I was trying to unpack that if statement and found myself confused and
wondering if one of those closing parentheses is misplaced. Currently the
double parentheses don't seem to be doing anything beyond what a single
parentheses would do, suggesting a possible typo. As it's written the
(Lower|Upper) == UpLo results in a bool which is bitwise anded with the int
UpLo. I may be being pedantic, but this doesn't seem technically safe as, I
believe, the bitwise representation of true and false are not specified in
the c++ standard. Am I missing something or is this an error in the code?
Mark
Loading...