Skip to content

Problems with header files and namespaces #740

@mreineck

Description

@mreineck

More or less by accident, I saw the following warning in one of the finufft CI logs today:

Warning: /home/runner/work/finufft/finufft/test/testutils.cpp:86:7: warning: using integer absolute value function 'abs' when argument is of floating point type [-Wabsolute-value]

This is bad. It means that abs is called on a floating point argument without having included <math.h> (<cmath> doesn't count - it only provides std::abs). As a consequence, the argument to abs will be truncated to integer, which is definitely not wanted.

Suggested workaround: always use std::abs and make sure that <cmath> is included.

(I'm not sure why "IWYU" is not catching this; but abs is a special case since it can show up in different system headers with different semantics ...)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions