Narrowing conversion warning/error when AlbertaGrid is used in combination with pqknodalbasis
The AlbertaGrid uses int
as IndexType. This causes some problems in the pqknodalbasis, since there a std::size_t
is fixed at some places.
-
Variant1: using
PQkNodalBasis<AlbertaGrid<DIM,DOW>::LeafGridView, k>
uses the default template parameterST=std::size_t
. This leads to the warning
pq1nodalbasis.hh:229:72: warning: narrowing conversion of /.../ from IndexSet<...>::IndexType {aka int}' to 'long unsigned int'
-
Variant2: using the
IndexType
of AlbertaGrid as parameter inPQkNodalBasis
, i.e.PQkNodalBasis<AlbertaGrid<DIM,DOW>::LeafGridView, k, AlbertaGrid<DIM,DOW>::LeafGridView::IndexSet::IndexType>
leads to the warning:
pqknodalbasis.hh:333:33: warning: narrowing conversion of /.../ from 'long unsigned int' to 'unsigned int'
The problem is the fixed std::size_t
in lines 202-209 in pqknodalbasis.hh
. Changing this to size_type
removes this warning but raises a new one:
defaultnodetorangemap.hh:58:27: warning: comparison between signed and unsigned integer expressions
that probably is much easier to resolve.
The point with this (narrowing conversion) warning is, that it is an error when using cmake and probably should be an error when following the c++-standard.