bug-bison
[Top][All Lists]
Advanced

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

Re: problems compiling groff with gcc-3.0.3


From: Akim Demaille
Subject: Re: problems compiling groff with gcc-3.0.3
Date: 28 Jan 2002 11:11:45 +0100
User-agent: Gnus/5.0808 (Gnus v5.8.8) XEmacs/21.4 (Common Lisp)

>>>>> "Werner" == Werner LEMBERG <address@hidden> writes:

>> So then it is probably the code that's old: Try to flip in a "using
>> namespace std;" somewhere appropriate.

Werner> No, no, no.  Definitely bison is the culprit!  groff doesn't
Werner> use *any* standard C++ headers or classes, so `namespace'
Werner> isn't an issue at all.  The argument `the code is old' is bad
Werner> IMHO.  If the code is cleanly written, avoiding any
Werner> problematic areas of C++ it should work with any C++ compiler.

Werner> As mentioned in another mail, 1.28 works nicely, and 1.31
Werner> seems to fail.

Hi Paul,

We have a problem with your cleaning patch, in the case of C++.  The
problem is when using alloca:

| /* The parser invokes alloca or malloc; define the necessary symbols.  */
| 
| # if YYSTACK_USE_ALLOCA
| #  define YYSTACK_ALLOC alloca
| #  define YYSIZE_T YYSTD (size_t)
| # else
| #  ifndef YYSTACK_USE_ALLOCA
| #   if defined (alloca) || defined (_ALLOCA_H)
| #    define YYSTACK_ALLOC alloca
| #    define YYSIZE_T YYSTD (size_t)
| #   else
| #    ifdef __GNUC__
| #     define YYSTACK_ALLOC __builtin_alloca
| #    endif
| #   endif
| #  endif
| # endif

Note that we defined YYSIZE_T and YYSTACK_ALLOC here.  Because of the
latter, the following block is skipped.

| # ifdef YYSTACK_ALLOC
|    /* Pacify GCC's `empty if-body' warning. */
| #  define YYSTACK_FREE(Ptr) do { /* empty */; } while (0)
| # else
| #  ifdef __cplusplus
| #   include <cstdlib> /* INFRINGES ON USER NAME SPACE */
| #   define YYSIZE_T std::size_t
| #  else
| #   ifdef __STDC__
| #    include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
| #    define YYSIZE_T size_t
| #   endif
| #  endif
| #  define YYSTACK_ALLOC YYSTD (malloc)
| #  define YYSTACK_FREE YYSTD (free)
| # endif


This results in no header being included at all when we use alloca.  I
get C is happy with it, but G++ 3.0 is not (this is groff):

make[2]: Entering directory `/tmp/groff-current/src/preproc/refer'
g++-3.0 -I. -I/tmp/groff-current/src/preproc/refer 
-I/tmp/groff-current/src/include -I/tmp/groff-current/src/include 
-DHAVE_CONFIG_H -g  -c label.cc
y.tab.c: In function `int yyparse()':
y.tab.c:903: `size_t' undeclared in namespace `std'

If I change the first block into

| # if YYSTACK_USE_ALLOCA
| #  define YYSTACK_ALLOC alloca
| #  define YYSIZE_T YYSTD (size_t)
| # else
| #  ifndef YYSTACK_USE_ALLOCA
| #   if defined (alloca) || defined (_ALLOCA_H)
| #    define YYSTACK_ALLOC alloca
| #    define YYSIZE_T YYSTD (size_t)
| #include <cstddef>
| #   else
| #    ifdef __GNUC__
| #     define YYSTACK_ALLOC __builtin_alloca
| #    endif
| #   endif
| #  endif
| # endif

i.e., adding cstddef, it works properly.

Given that we might have the same issue with C, given that you have
more experience in this area than I have, I'd really appreciate if you
could fix or suggest the right fix for Bison.  Today, it can compile
Groff properly.

Thanks!



reply via email to

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