Bug? Bitwise ops on shorts upconvert to ints and warning

Bug? Bitwise ops on shorts upconvert to ints and warning

Say I use this code to swap little with big endian, where *rp is a unsigned short *:

*rp = (*rp & 0xff00u) >> 8 | (*rp & 0x00ffu) << 8;

Result:

remark #810: conversion from "unsigned int" to "unsigned short" may lose significant bits

(with arrow pointing to the assignment)

At first I thought it saw the literal as an int, but then I replaced the expression by *rp & *rp and got the same error.

So, what gives? I didn't find any mention on the Web that bitwise ops upconverted to ints or unsigned ints.

1 contribution / 0 nouveau(x)
Reportez-vous à notre Notice d'optimisation pour plus d'informations sur les choix et l'optimisation des performances dans les produits logiciels Intel.