Subject: bin/29028: xlint doesn't warn on implicit long->integer conversions
To: None <gnats-admin@netbsd.org, netbsd-bugs@netbsd.org>
From: None <Peter.Bex@student.kun.nl>
List: netbsd-bugs
Date: 01/20/2005 22:24:00
>Number: 29028
>Category: bin
>Synopsis: xlint doesn't warn on implicit long->integer conversions, like it did in 1.6
>Confidential: no
>Severity: non-critical
>Priority: low
>Responsible: bin-bug-people
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Thu Jan 20 22:24:00 +0000 2005
>Originator: Peter Bex
>Release: NetBSD 2.0_RC1
>Organization:
>Environment:
System: NetBSD frohike.nvie.com 2.0_RC1 NetBSD 2.0_RC1 (FROHIKE) #3: Wed Sep 29 19:34:49 CEST 2004 root@:/usr/src/sys/arch/i386/compile/FROHIKE i386
Architecture: i386
Machine: i386
>Description:
Implicit casts of longs to integers (and possibly others) should
cause lint to complain, and it does this ``sometimes'' on
NetBSD 1.6.2, but on NetBSD 2.0 it never complains at all.
>How-To-Repeat:
------------------------ test.c -----------------------
#include <stdio.h>
int main(void)
{
long x = 10;
union { int integer; } y;
y.integer = x;
printf("%i\n", y.integer);
return 0;
}
-------------------------------------------------------
On NetBSD 1.6.2:
$ lint -ap test.c
test.c:
test.c(7): warning: conversion from 'long' may lose accuracy [132]
Lint pass2:
$ lint -p test.c
test.c:
Lint pass2:
$ lint -a test.c
test.c:
Lint pass2:
$
On NetBSD 2.0:
$ lint -ap test.c
test.c:
Lint pass2:
$ lint -p test.c
test.c:
Lint pass2:
$ lint -a test.c
test.c:
Lint pass2:
$
The -a option should make lint complain about longs which are
casted to integers. From the manpage:
-a Report assignments of long values to variables that are not
long.
Strangely the combination with the -p flag causes lint to complain on 1.6.2.
From the manpage:
-p Attempt to check portability of code to other dialects of C.
>Fix:
N/A
>Unformatted: