bug-bison
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bison-1.29 alloca & free bug


From: Hans Aberg
Subject: bison-1.29 alloca & free bug
Date: Fri, 12 Oct 2001 23:02:56 +0200

I have experienced a small problem with the bison-simple file: When I
compile the Bison generated parser, I get the errors:

Error   : function has no prototype
bison.simple line 417   free (yyss);

Error   : identifier 'free(...)' redeclared
was declared as: 'int (...)'
now declared as: 'void (void *)'
cstdlib line 80   void free(void *ptr);

These happens because bison.simple inlcudes free(), alloc() ect in a
somewhat messy way: In order to make alloca() work, I had to add to
bison.simple (in the beginning)
  #ifdef YYSTACK_USE_ALLOCA
  # undef YYSTACK_USE_ALLOCA
  # define YYSTACK_USE_ALLOCA 1
  # include <alloca.h>
  #endif
and in order to make malloc(), free() working I had to add
  #include <stdlib.h>
as under ISO C, this is where these functions are located.

Hoewver, when upgrading, I did not add the last one, as I worked with
alloca, which caused the problem to occur.

It seems me that the lines in bison.simple
  #if YYSTACK_USE_ALLOCA
  # define YYSTACK_ALLOC alloca
  #else
  # define YYSTACK_ALLOC malloc
  #endif
should be augmented with
  #if YYSTACK_USE_ALLOCA
  # define YYSTACK_DEALLOC(x)
  #else
  # define YYSTACK_DEALLOC(x) free(x)
  #endif
and instead of free(), one should use YYSTACK_DEALLOC(x) in the code.

  Hans Aberg





reply via email to

[Prev in Thread] Current Thread [Next in Thread]