'BSD C compiler bug'

brian at bucc2.UUCP brian at bucc2.UUCP
Wed Mar 23 19:35:00 AEST 1988


> /* Written  7:55 pm  Mar 18, 1988 by mtxinu.UUCP!tim in bucc2:comp.lang.c */
> /* ---------- "'BSD C compiler bug'" ---------- */
> Subject: BSD C compiler bug?
> Newsgroups: comp.unix,comp.lang.c
> Keywords: comma notation
> 
> 
> There seems to be a bug with comma notation in BSD C.  (It shows up
> on the Ultrix, MORE/BSD and Sun compilers, FYI).
> 
> This program:
>      1		# define NULL	0
>      2		main()
>      3		{
>      4			unsigned char	**foo;
>      5			int		fn();
>      6	
>      7			foo = NULL;
>      8			foo = (NULL, NULL);
>      9			foo = ( !foo ? NULL : (fn(2), NULL) );
>     10		}
>     11	
>     12		fn(a)
>     13		int	a;
>     14		{ return (a); }
>     15	
> gets 'cc' errors:
> "comma.c", line 8: warning: illegal combination of pointer and integer, op =
> "comma.c", line 9: warning: illegal combination of pointer and integer, op =

  I _think_ changing those NULL's on lines 8,9 to (unsigned char **) NULL will
eliminate these warnings.

...............................................................................

  When the going gets weird, the weird turn pro.

  Brian Michael Wendt       UUCP: {cepu,ihnp4,uiucdcs,noao}!bradley!brian
  Bradley University        ARPA: cepu!bradley!brian at seas.ucla.edu
  (309) 691-5175            ICBM: 40 40' N  89 34' W



More information about the Comp.lang.c mailing list