Subject: toolchain/26933: lint incorrectly warns of right-shift of unsigned short
To: None <>
From: None <>
List: netbsd-bugs
Date: 09/12/2004 18:07:04
>Number:         26933
>Category:       toolchain
>Synopsis:       lint incorrectly warns of right-shift of unsigned short
>Confidential:   no
>Severity:       critical
>Priority:       high
>Responsible:    toolchain-manager
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Mon Sep 13 01:06:00 UTC 2004
>Originator:     Jason R Thorpe
>Release:        NetBSD 2.0G
        -- Jason R. Thorpe <>
System: NetBSD 2.0G NetBSD 2.0G (YEAH-BABY-XP) #26: Thu Jul 15 08:26:49 PDT 2004 i386
Architecture: i386
Machine: i386
	Lint incorrectly issues the following warning:

lintbug.c(5): warning: bitwise operation on signed value possibly nonportable [117]

	when it encounters a right-shift of an unsigned short in
	certain cases.

	Run the following test case through:

	lint -chapbxzF -w -X 272 -i

bug(unsigned char *p, unsigned short u)

	*p = (u >> 8) & 0xffU;

	Changing the "unsigned short" in the test case to "unsigned int"
	causes the warning to go away.  Lint is possibly mis-promoting
	the argument?

	Worth noting that the following test case also fails:

bug(unsigned char *p, unsigned int x)
	unsigned short u = x & 0xffffU;

	*p = (u >> 8) & 0xffU;

	Ok, so maybe lint is just totally screwing up "unsigned short".