Open Bug 1072317 Opened 5 years ago Updated 2 years ago

numerous instances of warning C4334 '<<' : result of 32-bit shift implicitly converted to 64 bits (was 64-bit shift intended?)

Categories

(Firefox Build System :: General, defect)

x86_64
Windows 7
defect
Not set

Tracking

(Not tracked)

People

(Reporter: froydnj, Unassigned)

References

(Blocks 1 open bug)

Details

This warning appears to be unhelpful; the warnings seem to be triggered by code like:

  (1 << mPaletteDepth) * sizeof(uint32_t); // imgFrame.h

or:

  cost[0][1 << i] = ... // opus_encoder.c, cost is a float[][]

or:

  bin->reg_size = (1U << (TINY_MIN_2POW + i)); // jemalloc.c

In all these cases, relying on the implicit upcast to a wider type is intended and desirable.  I think we should disable the warning.
Why not make those casts explicit instead. I've seen sec bugs in the past due to bit shifting mistakes.
(In reply to Justin Wood (:Callek) from comment #1)
> Why not make those casts explicit instead. I've seen sec bugs in the past
> due to bit shifting mistakes.

Are they sec bugs because of upcasts to a wider type, or were they sec bugs because of off-by-one errors or something else?
Flags: needinfo?(bugspam.Callek)
iirc it was off-by-one errors, specifically conversions that were intended to either have a dropped leftmost bit due to the shift.  Or even things that don't realize they are being converted and are stored in memory allocated for 32 bits, etc. etc.

No concrete bugs to point at though.
Flags: needinfo?(bugspam.Callek)
Depends on: 1229189
No longer depends on: 1229189
Depends on: 1229196
Depends on: 1266614
Depends on: 1266615
Product: Core → Firefox Build System
You need to log in before you can comment on or make changes to this bug.