Opened 10 years ago

Closed 10 years ago

#7160 closed defect (invalid)

Implicit sign extension

Reported by: Erik Hovland <erik@…> Owned by: Isaac Richards
Priority: trivial Milestone: unknown
Component: MythTV - General Version: head
Severity: low Keywords:
Cc: Ticket locked: no

Description

When going from one fixed signed type to a larger (signed or unsigned) through implicit casting, the caller might be accidentally extending the sign bit. It is likely better to explicitly cast before manipulation to the final value. There is a case of this implicit sign extension in FrequencyListDescriptor::Frequency() in libmythtv.

Attachments (1)

libs_libmythtv-sign-extension (1.2 KB) - added by Erik Hovland <erik@…> 10 years ago.
Use explicit casting to avoid implicit sign extensions

Download all attachments as: .zip

Change History (2)

Changed 10 years ago by Erik Hovland <erik@…>

Use explicit casting to avoid implicit sign extensions

comment:1 Changed 10 years ago by Janne Grunau

Milestone: unknown
Resolution: invalid
Status: newclosed

shouldn't be a problem since _data is (unsigned char*)

Note: See TracTickets for help on using tickets.