Closed
Bug 1073716
Opened 11 years ago
Closed 11 years ago
clang 3.5 warnings for "using integer absolute value function 'abs' when argument is of floating point type [-Wabsolute-value]"
Categories
(Core :: General, defect)
Tracking
()
RESOLVED
FIXED
mozilla35
People
(Reporter: dholbert, Assigned: dholbert)
References
Details
Attachments
(1 file)
|
5.83 KB,
patch
|
ehsan.akhgari
:
review+
|
Details | Diff | Splinter Review |
No description provided.
| Assignee | ||
Comment 1•11 years ago
|
||
Using clang 3.5 on Ubuntu 14.10 final beta (which is a trunk-ish version of clang -- newer than 3.5 in Ubuntu 14.04), I get several warnings like this when building m-c, which break my build because they're in FAIL_ON_WARNINGS directories:
{
gfx/2d/Path.cpp:255:43: error: using integer absolute value function 'abs' when argument is of floating point type [-Werror,-Wabsolute-value]
1:02.30 t = 2 * Float(sqrt(aTolerance / (3. * abs(s3))));
1:02.30 ^
}
Here, s3 is float-typed, as the warning text says. In another instance, we get the same warning for an int64_t.
This happens because "abs" comes from C, and is documented here as just taking "int". Other types have their own differently-named functions "fabs", "fabsl", "labs", and "llabs" (in C):
http://en.cppreference.com/w/c/numeric/math/abs
Fortunately, C++ has std::abs which seems to have versions for pretty much any numeric type:
http://en.cppreference.com/w/cpp/numeric/math/abs
http://en.cppreference.com/w/cpp/numeric/math/fabs
...which is why the warning-text recommends using it.
Summary: clang 3.5 warnings for → clang 3.5 warnings for "using integer absolute value function 'abs' when argument is of floating point type [-Wabsolute-value]"
| Assignee | ||
Comment 2•11 years ago
|
||
Attachment #8496493 -
Flags: review?(ehsan.akhgari)
| Assignee | ||
Updated•11 years ago
|
Assignee: nobody → dholbert
Status: NEW → ASSIGNED
Updated•11 years ago
|
Attachment #8496493 -
Flags: review?(ehsan.akhgari) → review+
| Assignee | ||
Comment 3•11 years ago
|
||
Flags: in-testsuite-
Comment 4•11 years ago
|
||
Status: ASSIGNED → RESOLVED
Closed: 11 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla35
Updated•11 years ago
|
Flags: qe-verify-
You need to log in
before you can comment on or make changes to this bug.
Description
•