[comp.os.minix] lib/malloc.c change request

clark@ttidca.TTI.COM (Ralph Clark) (06/13/88)

Using the 1.2 compiler, I've encountered what seems to be a variable scope
bug; static variable declarations do not override global declarations in
other files, and cause the similar name to be multiply defined.

I found this in lib/malloc.c, which declares static names top, bottom,
(and in 1.3, empty). These names are quite likely to occur as global names
in another file. I'd like to request that in MINIX 1.3, these be changed
in malloc.c to _bottom, _top, and _empty to get around this problem with
the 1.2 compiler.

The following program will illustrate the problem, complaining that top
is multiple declared in malloc.s :
 ------------ cut ---------------
 /* test-top.c - test for multiple declared symbol */
extern char *malloc();
int top;

main()
  {
  char *x;

  x = malloc();
  top = 2;
  }
 ------------- end -------------
-- 
Ralph Clark (clark@ttidca.TTI.COM) {csun|philabs|psivax|trwrb}!ttidca!clark

ast@cs.vu.nl (Andy Tanenbaum) (06/19/88)

In article <2686@ttidca.TTI.COM> clark@ttidca.TTI.COM (Ralph Clark) writes:
>static variable declarations do not override global declarations in
>other files, and cause the similar name to be multiply defined.
I think the bug is that static is exported beyond the file, which it
shouldn't be.  I'll change top, bottom and empty in malloc to _top,
_bottom, and _empty.

Andy Tanenbaum (ast@cs.vu.nl)
-- 
Andy Tanenbaum (ast@cs.vu.nl)