On Thu, 30 Jan 2020 at 08:25, Smith, Barry F. <[email protected]> wrote:
> > > > On Jan 27, 2020, at 3:42 PM, Lisandro Dalcin <[email protected]> wrote: > > > > +#if defined(__GNUC__) && (__GNUC__ >= 4) > > +#pragma GCC system_header > > +#endif > > + > > #define PETSC_CXX_COMPLEX_FIX(Type) \ > > static inline PetscComplex operator+(const PetscComplex& lhs, const > Type& rhs) { return const_cast<PetscComplex&>(lhs) + PetscReal(rhs); } \ > > static inline PetscComplex operator+(const Type& lhs, const > PetscComplex& rhs) { return PetscReal(lhs) + > const_cast<PetscComplex&>(rhs); } \ > > > > Would that be an acceptable solution o we should rather implement a > configure test and define PETSC_HAVE_PRAGMA_GCC_SYSTEM_HEADER ? > > I'm fine with having it handled by the version check. > > Thanks. > > > These are the kind of errors that show up for EVERY C++ source compile > if -Wfloat-equal is passed. > > > > /home/devel/petsc/dev/include/petsccxxcomplexfix.h: In function ‘bool > operator==(const PetscComplex&, const PetscInt&)’: > > /home/devel/petsc/dev/include/petsccxxcomplexfix.h:47:134: warning: > comparing floating point with == or != is unsafe [-Wfloat-equal] > > 47 | static inline bool operator==(const PetscComplex& lhs, const > Type& rhs) { return const_cast<PetscComplex&>(lhs).imag() == PetscReal(0) > && const_cast<PetscComplex&>(lhs).real() == PetscReal(rhs); } \ > > | > ^ > > /home/devel/petsc/dev/include/petsccxxcomplexfix.h:60:1: note: in > expansion of macro ‘PETSC_CXX_COMPLEX_FIX’ > > 60 | PETSC_CXX_COMPLEX_FIX(PetscInt) > > I don't understand the above. Are these two unrelated issues? Or does > adding the first chunk of code prevent the warnings from the second chunk > of code. > > Yes, that's it. using `#pragma GCC system_header` suppresses all warnings in that header file, including of course `-Wfloat-equal`. -- Lisandro Dalcin ============ Research Scientist Extreme Computing Research Center (ECRC) King Abdullah University of Science and Technology (KAUST) http://ecrc.kaust.edu.sa/
