[7890] in Athena Bugs
Bug in Ultrix 4.2 cc2.1 compiler:
daemon@ATHENA.MIT.EDU (Theodore Ts'o)
Thu Aug 8 16:43:16 1991
Date: Thu, 8 Aug 91 16:43:24 -0400
From: tytso@ATHENA.MIT.EDU (Theodore Ts'o)
To: bugs@ATHENA.MIT.EDU
Reply-To: tytso@ATHENA.MIT.EDU
Take this sample program file, which as far as I can tell, is legal ANSI
C:
--- cut here ----
typedef struct node NODE;
struct node {
struct node *nd_next;
};
extern void web_allnodes ( void (*func)(NODE *n) );
typedef struct node_list {
struct node *n;
} NLIST;
extern void nlist_build (int dir, struct node *n, unsigned short levels);
static NLIST nlist[10];
main()
{
nlist[0].n = 0;
}
--- cut here ----
It produces the following error:
ccom: Error: foo.c, line 19: n undefined
nlist[0].n = 0;
-----------^
ccom: Error: foo.c, line 19: member of structure or union required
nlist[0].n = 0;
-----------^
=======================================
But wait! It gets better! If you change the line:
extern void web_allnodes ( void (*func)(NODE *n) );
to the functionally equivalent: (because NODE is a typedef for struct node)
extern void web_allnodes ( void (*func)(struct node *n) );
you get the following error message:
(ccom): foo.c, line 7: ccom: Internal: tyreduce
extern void web_allnodes ( void (*func)(struct node *n) );
-------------------------------------------------------------^
=====================================================
And, if you rearrange the lines for the extern void web_allnodes,
typedef ... NLIST, and extern void nlist_build, in almost any other
order, the C compiler will compile the program without any complaints:
This order works:
typedef struct node_list {
struct node *n;
} NLIST;
extern void web_allnodes ( void (*func)(NODE *n) );
extern void nlist_build (int dir, struct node *n, unsigned short levels);
... as does this order:
extern void web_allnodes ( void (*func)(NODE *n) );
extern void nlist_build (int dir, struct node *n, unsigned short levels);
typedef struct node_list {
struct node *n;
} NLIST;
Dec should have a fun time with this one.... this is almost as good as
what cc1.31 does when it sees a function with ANSI prototypes --- ccom
coredumps! :-)
- Ted