C++ Cfront bug? [2]
1 messages in this thread
[Continued]
Here is the code that demonstrates a bug that I think (but am not
sure) is an AT&T bug or a Comeau Computing bug. By merely
declaring two objects of similar but distinctly named classes
(just before function "main"), I get the error:
"aplist.h", line 116: internal <<AT&T USL C++ Language System <3.0> 09/15/91>> error: table.grow( 5, 5)
Whose bug is this? Incidently, if I remove the list iteration
stuff, the bug disappears.
————————— cut here —————————-
#include <string.h>
struct slink
{
slink* next;
slink() { next = 0; }
slink(slink* p) { next = p; }
};
class slist_base
{
slink* last;
public:
void insert(slink*);
slink* get(); // remove and return head of list
void clear() { last = 0; }
slist_base() { last = 0; }
slist_base(slink* a) { last = a->next = a; }
friend class slist_base_iter;
};
void slist_base::insert(slink* a)
{
if (last)
a->next = last->next;
else
last = a;
last->next = a;
}
slink* slist_base::get()
{
// error check: if (last == 0) …
slink* f = last->next;
if (f == last)
last = 0;
else
last->next = f->next;
return f;
};
/* Declare a list iterator. See p. 267, C++ Programming Language, 2nd ed.
Return 0 for all types: not ideal for all types, but fine for pointers.
*/
class slist_base_iter
{
slink* ce; // current element
slist_base* cs; // current list
public:
slist_base_iter(slist_base& s) { cs = &s; ce = cs->last; }
};
[More]