[Top][All Lists]

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

Re: Bison 1.30f

From: Hans Aberg
Subject: Re: Bison 1.30f
Date: Sat, 15 Dec 2001 16:58:21 +0100

At 13:51 +0100 2001/12/15, Hans Aberg wrote:
>The second problem is that one has
>  union yyalloc *yyptr = ...
>  union yyalloc
>  {
>    short yyss;
>    YYSTYPE yyvs;
>    YYLTYPE yyls;
>  # endif
>  };
>and unions are under C++ only allowed (or so I recall) for POD's (plain
>ol' data's), basically data types which does not have non-trivial
>So I am not really sure why my code compiled, as my YYSTYPE contains
>non-default constructors.

I looked this up, the C++ standard, verse 9.5:1, says about unions:
  An object of a class with a non-trivial constructor (12.1), a non-trivial
copy constructor (12.8), a non-trivial destructor (12.4), or a non-trivial
copy assignment operator (13.5.3, 12.8) cannot be a member of a union, nor
can an
array of such objects.

So if a compiler has implemented C++ according to this, union yyalloc
should not compile if YYSTYPE has one of the above non-trivial
constructors. And the reason it compiled was that my C++ compiler is bad,
it seems.

Therefore, it may be prudent implementing genuine C++ support before C++
compilers become better, causing the code to fail. :-)

  Hans Aberg

reply via email to

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