Opened 6 years ago

Closed 6 years ago

#118 closed defect (fixed)

Incorrect bit shift warning

Reported by: Thierry Delisle Owned by: a3moss
Priority: major Component: cfa-cc
Version: 1.0 Keywords:
Cc:

Description (last modified by Thierry Delisle)

The following code:

extern "C" {
#include <sys/sysmacros.h>
}

int main() { return 0; }

produces the following warning

/usr/include/x86_64-linux-gnu/sys/sysmacros.h: In function ‘gnu_dev_major’:
/usr/include/x86_64-linux-gnu/sys/sysmacros.h:41:145: warning: right shift count >= width of type [-Wshift-count-overflow]
   return ((__dev >> 8) & 0xfff) | ((unsigned int) (__dev >> 32) & ~0xfff);

Command used :

cfa-1.0 test.cfa -Wall -Wextra -O2 

Change History (4)

comment:1 Changed 6 years ago by Thierry Delisle

Description: modified (diff)

comment:2 Changed 6 years ago by a3moss

Under -O2 the preprocessor generates a body for gnu_dev_major that it does not generate at -O0.

Last edited 6 years ago by a3moss (previous) (diff)

comment:3 Changed 6 years ago by a3moss

Shorter test case:

int main() {
	unsigned long long dev = 0;
	unsigned ret = (unsigned)(dev >> 32);
}
Version 0, edited 6 years ago by a3moss (next)

comment:4 Changed 6 years ago by a3moss

Resolution: fixed
Status: assignedclosed

Backed out change to CastExpr resolution that changed cast costs; concurrently removed specialization cost from return types in new cost model.

Note: See TracTickets for help on using tickets.