NetBSD Problem Report #26933

Received: (qmail 17639 invoked by uid 605); 13 Sep 2004 01:05:45 -0000
Message-Id: <20040913010704.98B511E0A1C@yeah-baby.shagadelic.org>
Date: Sun, 12 Sep 2004 18:07:04 -0700 (PDT)
From: thorpej@shagadelic.org
Sender: gnats-bugs-owner@NetBSD.org
Reply-To: thorpej@shagadelic.org
To: gnats-bugs@gnats.NetBSD.org
Subject: lint incorrectly warns of right-shift of unsigned short
X-Send-Pr-Version: 3.95

>Number:         26933
>Category:       toolchain
>Synopsis:       lint incorrectly warns of right-shift of unsigned short
>Confidential:   no
>Severity:       critical
>Priority:       high
>Responsible:    thorpej
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Mon Sep 13 01:06:00 +0000 2004
>Closed-Date:    Mon Sep 13 01:25:55 +0000 2004
>Last-Modified:  Mon Sep 13 02:30:01 +0000 2004
>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:
State-Changed-From-To: open->closed 
State-Changed-By: thorpej 
State-Changed-When: Mon Sep 13 01:25:26 UTC 2004 
State-Changed-Why:  
Sigh, not a bug: 

To quote C99 6.3.1.1: 

If an int can represent all values of the original type, the value is 
converted to an int; otherwise, it is converted to an unsigned int. These 
are called the integer promotions. 48) All other types are unchanged by 
the integer promotions. 


Responsible-Changed-From-To: toolchain-manager->thorpej 
Responsible-Changed-By: thorpej 
Responsible-Changed-When: Mon Sep 13 01:25:26 UTC 2004 
Responsible-Changed-Why:  
I closed the PR. 

From: christos@zoulas.com (Christos Zoulas)
To: thorpej@shagadelic.org, gnats-bugs@gnats.NetBSD.org
Cc:  
Subject: Re: toolchain/26933: lint incorrectly warns of right-shift of unsigned short
Date: Sun, 12 Sep 2004 22:29:52 -0400

 On Sep 12,  6:07pm, thorpej@shagadelic.org (thorpej@shagadelic.org) wrote:
 -- Subject: toolchain/26933: lint incorrectly warns of right-shift of unsigne


 The only portable shit is unsigned int.

 christos

 | >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:
 |  	
 |  	
 -- End of excerpt from thorpej@shagadelic.org


>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.39 2013/11/01 18:47:49 spz Exp $
$NetBSD: gnats_config.sh,v 1.8 2006/05/07 09:23:38 tsutsui Exp $
Copyright © 1994-2007 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.