Warn on unnecessary float->double conversion

RESOLVED WONTFIX

Status

P5
enhancement
RESOLVED WONTFIX
9 years ago
19 days ago

People

(Reporter: jrmuizel, Unassigned)

Tracking

Trunk

Firefox Tracking Flags

(Not tracked)

Details

(Reporter)

Description

9 years ago
qcms has a bunch of code like:

float p;
...
p *= 65535.;

Since the type of 65535. is a double this code will promote p to a double to do the multiply. This causes the, likely unintended, conversion to double and conversion back to float.

It would be nice if we could warn about situations like this.

Updated

9 years ago
Blocks: 430328

Comment 1

9 years ago
I am a student from SJCE, Mysore India and would like to take up this bug.
Assignee: nobody → prarthanasjce
FWIW, GCC >= 4.6 already has an option to do this (-Wdouble-promotion).  The implementation was straightforward; I don't think it would be too hard to port it to clang, if it's not already there.

Comment 3

7 years ago
Sounds like a good minor reason to bump gcc...if anyone feels bored :)

Updated

9 months ago
Product: Core → Firefox Build System
clang also supports the -Wdouble-promotion warning:

> warning: implicit conversion increases floating-point precision: A to B

https://clang.llvm.org/docs/DiagnosticsReference.html#wdouble-promotion
OS: Mac OS X → Unspecified
Hardware: x86 → Unspecified
P5 because this warning is very noisy and, AFAIU, is a performance problem, not a correctness bug.
Assignee: prarthanasjce → nobody
Priority: -- → P5
I don't think we will ever fix that, closing.
Severity: normal → enhancement
Status: NEW → RESOLVED
Last Resolved: 19 days ago
Resolution: --- → WONTFIX
You need to log in before you can comment on or make changes to this bug.