Subject: Annoying gcc bug
To: None <port-m68k@NetBSD.ORG>
From: Scott Reynolds <scottr@og.org>
List: port-m68k
Date: 12/18/1996 01:32:08
There appears to be a problem with -O vs. -Wall on m68k machines running
gcc 2.7.2 and 2.7.2.1. The following excerpt from calcru() in
kern_resource.c gets the point across pretty clearly, I think.
Anyone with gcc (or general compiler) clue care to take a stab at this?
--scott
# This is a shell archive. Save it in a file, remove anything before
# this line, and then unpack it by entering "sh file". Note, it may
# create directories; files and directories will be owned by you and
# have default permissions.
#
# This archive contains:
#
# moof.c
#
echo x - moof.c
sed 's/^X//' >moof.c << 'END-of-moof.c'
X/*
X * What follows is a snippet of the NetBSD-current kernel file
X * src/sys/kern/kern_resource.c that I've found causes gcc lossage.
X *
X * Compile me on an m68k-based NetBSD system using gcc 2.7.2 or 2.7.2.1
X * with the following command:
X *
X * cc -c -O -Wall moof.c
X *
X * Then, be surprised to see:
X *
X * moof.c: In function `calcru':
X * moof.c:37: warning: `u' might be used uninitialized in this function
X *
X * This is clearly a bug. (A similar problem turns up in
X * src/sys/nfs/nfs_vnops.c in nfs_writebp() wrt the `off' variable.)
X */
X
X#define _KERNEL
X#include <sys/param.h>
X#include <sys/types.h>
X#include <sys/kernel.h>
X#include <sys/time.h>
X#include <sys/proc.h>
X
X/*
X * Transform the running time and tick information in proc p into user,
X * system, and interrupt time usage.
X */
Xvoid
Xcalcru(p, up, sp, ip)
X register struct proc *p;
X register struct timeval *up;
X register struct timeval *sp;
X register struct timeval *ip;
X{
X register u_quad_t u, st;
X register long sec, usec;
X
X st = p->p_sticks;
X sec = p->p_rtime.tv_sec;
X usec = p->p_rtime.tv_usec;
X
X u = (u_quad_t) sec * 1000000 + usec;
X st = (u * st);
X sp->tv_sec = st / 1000000;
X}
END-of-moof.c
exit