help-bison
[Top][All Lists]
Advanced

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

Re: member with constructor not allowed in union


From: Hans Aberg
Subject: Re: member with constructor not allowed in union
Date: Thu, 14 Mar 2002 22:37:01 +0100

At 16:27 +0100 2002/03/14, Richard B. Kreckel wrote:
>Okay, I just gave the current CVS sources a try and it does not seem to
>help.  The section
>  /* A type that is properly aligned for any stack member.  */
>  union yyalloc
>  {
>    short yyss;
>    YYSTYPE yyvs;
>  # if YYLSP_NEEDED
>    YYLTYPE yyls;
>  # endif
>  };
>is still generated in my file input_parser.cc and later I get the error
>y.tab.c:154: member `class GiNaC::ex GiNaC::yyalloc::yyvs' with
>constructor not allowed in union
>
>Actually, this is all somewhat beyond me.

The current bison.simple implements for C a dynamic stack which is used
when the static stack has run out of space; it uses the type yyalloc in
order to compute some stack alignments.

Under C++, it is not allowed to have types with non-trivial constructors
within a union, so proper C++ compilers should reject such code (even
though older ones did not).

But, as the C dynamic stack uses raw memory copy (memcpy) for
re-allocation, it does not invoke any C++ copy-constructors, so it would
not work anyway under C++.

The fix I made was to use proper C++ containers for stack (such as
std::deque, etc.); I then had to tweak the Bison sources a bit as well.

  Hans Aberg





reply via email to

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