Subject: toolchain/26933: lint incorrectly warns of right-shift of unsigned short
To: None <gnats-bugs@gnats.NetBSD.org>
From: None <thorpej@shagadelic.org>
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
>Closed-Date:
>Last-Modified:
>Originator: Jason R Thorpe
>Release: NetBSD 2.0G
>Organization:
-- Jason R. Thorpe <thorpej@shagadelic.org>
>Environment:
System: NetBSD yeah-baby.shagadelic.org 2.0G NetBSD 2.0G (YEAH-BABY-XP) #26: Thu Jul 15 08:26:49 PDT 2004 thorpej@yeah-baby.shagadelic.org:/u1/netbsd/src/sys/arch/i386/compile/YEAH-BABY-XP i386
Architecture: i386
Machine: i386
>Description:
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.
>How-To-Repeat:
Run the following test case through:
lint -chapbxzF -w -X 272 -i
void
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:
void
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".
>Fix:
>Release-Note:
>Audit-Trail:
>Unformatted: