Warn on unnecessary float->double conversion

NEW
Assigned to

Status

()

Core
Rewriting and Analysis
8 years ago
5 years ago

People

(Reporter: jrmuizel, Assigned: Prarthana)

Tracking

(Blocks: 1 bug)

Trunk
x86
Mac OS X
Points:
---

Firefox Tracking Flags

(Not tracked)

Details

(Reporter)

Description

8 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

8 years ago
Blocks: 430328
(Assignee)

Comment 1

8 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

5 years ago
Sounds like a good minor reason to bump gcc...if anyone feels bored :)
You need to log in before you can comment on or make changes to this bug.