[Top][All Lists]

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

Re: Bison 1.30f

From: Paul Eggert
Subject: Re: Bison 1.30f
Date: Wed, 12 Dec 2001 12:26:09 -0800 (PST)

> Date: Tue, 11 Dec 2001 12:58:50 +0100
> From: Hans Aberg <address@hidden>
> I get the following output, which is not in the skeleton file:
>   ...
>   #include <stdio.h>

I agree that this shouldn't be in the output, as <stdio.h> intrudes on
the user's namespace.  This is true for both C and C++.

The skeleton file already includes <stdio.h> only if necessary (when
debugging is enabled); I see no reason to double-include it.

> Also, if I put in my .y file:
>   #define YYSTACK_USE_ALLOCA 1

The manual says "Don't do that" (:-).  Here's a quote from the manual:

     Macro used to control the use of `alloca'. If defined to `0', the
     parser will not use `alloca' but `malloc' when trying to grow its
     internal stacks. Do _not_ define `YYSTACK_USE_ALLOCA' to anything

Currently, if the user ignores the manual and defines
YYSTACK_USE_ALLOCA to a nonzero value, it is the user's responsibility
to define alloca and size_t appropriately.  This infringes on the
user's name space, but I don't see a trivial fix for this.  I'm
inclined to leave this alone for now, until we can think of a good fix
and test it.  It's low priority, as we are in the realm of
undocumented (and even warned-against!) behavior.

> As for the comment (a little further down):
> #      include <alloca.h> /* INFRINGES ON USER NAME SPACE */
> it should probably be
> #      include <alloca.h> /* MAY INFRINGE ON USER NAME SPACE */

As far as I know, <alloca.h> does infringe on the user name space in
all cases where <alloca.h> is actually included here.  Do you know of
a counterexample?

> When YYSTACK_USE_ALLOCA is not defined, it currently merely chooses malloc,
> etc; this is OK with me. But I figure it means that the portion of the
> alloca test:
> #   if defined (alloca) || defined (_ALLOCA_H)
> #    define YYSTACK_ALLOC alloca
> #    define YYSIZE_T size_t
> will never be used.

Yes, it might be used.  For example, if the .y file starts like this:

   #include <alloca.h>

and if alloca.h defines alloca or _ALLOCA_H (which is typical), then
it will be used.

> You have forgotten to pick out some comments, such as:
>   # ifdef __cplusplus
>   #  include <cstddef> /* INFRINGES ON USER NAME SPACE */
>   #  define YYSIZE_T std::size_t
> as it now does not infringe on namespaces.

Don't the macros defined by <cstddef> infringe on the user namespace?
For example, doesn't <cstddef> define a macro NULL?  That would
infringe on the user name space.

> Modulo the above said, it compiled in the various YYSTACK_USE_ALLOCA
> combinations, though.

OK, I'll write up a revised patch, with the above comments in mind.
Thanks for your careful review of the code.

reply via email to

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