4.?bsd cc and lint mistreat wild structure use (with fix)
Arthur David Olson
ado at elsie.UUCP
Fri Feb 22 02:23:32 AEST 1985
> struct xy {
> int x;
> int y;
> } a;
> main()
> {
> struct xy *p;
> p = &a;
> if (*p) {
> /* compiler error: zzzcode- bad type */
> }
> }
Index: lib/mip/trees.c Fix
Description:
The "cc" command gives cryptic messages when structures are used wildly;
the "lint" command fails to give messages.
Repeat-By:
echo "struct { int x; } a; main() { a || a; }" > try.c
cc try.c
lint try.c
Fix:
The trade secret status of the code precludes a clearer posting.
The file is named "/usr/src/cmd/mip/trees.c" in 4.1bsd.
ed lib/mip/trees.c
/^buildtree/;/OTHER/;/switch/a
#ifndef OLDVERSION
case QUEST:
case CBRANCH:
case ANDAND:
case OROR:
if (l->in.type == STRTY || l->in.type == UNIONTY ||
((o == ANDAND || o == OROR) &&
(r->in.type == STRTY || r->in.type == UNIONTY)))
uerror("wild use of structure or union");
break;
#endif
.
/^opact/;/case CBRANCH/i
#ifdef OLDVERSION
.
/return/a
#else
return 0;
case CBRANCH:
case ANDAND:
case OROR:
return OTHER;
#endif
/case QUEST/a
#ifndef OLDVERSION
return (mt2 & MENU) ? (TYPR + NCVTR + OTHER) : (TYPR + OTHER);
#endif
.
w
q
--
UUCP: ..decvax!seismo!elsie!ado ARPA: elsie!ado at seismo.ARPA
DEC, VAX and Elsie are Digital Equipment and Borden trademarks
More information about the Comp.bugs.4bsd.ucb-fixes
mailing list