lint goofs structure type compatibility

Chris Torek chris at mimsy.UUCP
Fri Apr 8 07:33:32 AEST 1988


Index: usr.bin/lint/Makefile 4.3BSD Fix

Description:
	Some time ago, someone noted in comp.lang.c that 4BSD lint
	apparently believes that any two structures are compatible as
	long as their sizes are the same.  Lint was coded to believe
	that structures are compatible when their names *and* sizes are
	the same, but due to a small goof, gets this wrong.  (I fixed
	this some time ago for an unrelated problem that does not occur
	in 4.3BSD as distributed, but only recently noticed that it
	fixes this bug too, hence the late posting.)

Repeat-by:
	Run lint on the following file:

		struct foo { char *p; };
		struct bar { int *p; };

		f(x) struct foo *x; { x=x; }
		main() { f((struct bar *)0); }

	It should complain, but does not.

Fix:
	hash.c has code that is conditioned on #ifdef FLEXNAMES, but 
	does not include config.h and thinks FLEXNAMES is not defined.

RCS file: RCS/Makefile,v
retrieving revision 1.1
retrieving revision 1.2
diff -c2 -r1.1 -r1.2
*** /tmp/,RCSt1022038	Thu Apr  7 17:16:57 1988
--- /tmp/,RCSt2022038	Thu Apr  7 17:16:58 1988
***************
*** 93,97 ****
  lpass2.o: $M/manifest.h lmanifest.h pcclocal.h macdefs.h
  	${CC} ${CFLAGS} -c -I$M -I. lpass2.c
! 	
  lintall:
  	lint -hpv -I. -I$M  $M/cgram.c $M/xdefs.c $M/scan.c \
--- 93,100 ----
  lpass2.o: $M/manifest.h lmanifest.h pcclocal.h macdefs.h
  	${CC} ${CFLAGS} -c -I$M -I. lpass2.c
! 
! hash.o: hash.c
! 	${CC} ${CFLAGS} -c -I$M -I. hash.c
! 
  lintall:
  	lint -hpv -I. -I$M  $M/cgram.c $M/xdefs.c $M/scan.c \
RCS file: RCS/hash.c,v
retrieving revision 1.1
diff -c2 -r1.1 hash.c
*** /tmp/,RCSt1022220	Thu Apr  7 17:30:53 1988
--- hash.c	Sat Apr  2 02:44:36 1988
***************
*** 1,5 ****
  #ifndef lint
! static char sccsid[] = "@(#)hash.c	1.1	(Berkeley)	3/29/83";
  #endif lint
  
  /*
--- 1,7 ----
  #ifndef lint
! static char sccsid[] = "@(#)hash.c	1.2	(Berkeley)	9/28/87";
  #endif lint
+ 
+ #include "config.h"
  
  /*
-- 
In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 7163)
Domain:	chris at mimsy.umd.edu	Path:	uunet!mimsy!chris



More information about the Comp.lang.c mailing list