From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 32052 invoked by alias); 29 Sep 2002 21:03:21 -0000 Mailing-List: contact gcc-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-owner@gcc.gnu.org Received: (qmail 32045 invoked from network); 29 Sep 2002 21:03:21 -0000 Received: from unknown (HELO windlord.stanford.edu) (171.64.13.23) by sources.redhat.com with SMTP; 29 Sep 2002 21:03:21 -0000 Received: (qmail 1446 invoked by uid 50); 29 Sep 2002 21:03:20 -0000 To: gcc@gcc.gnu.org Subject: Re: module level flags References: <20020929203840.16208F2D6A@nile.gnat.com> In-Reply-To: <20020929203840.16208F2D6A@nile.gnat.com> (dewar@gnat.com's message of "Sun, 29 Sep 2002 16:38:40 -0400 (EDT)") From: Russ Allbery Organization: The Eyrie Date: Sun, 29 Sep 2002 14:52:00 -0000 Message-ID: User-Agent: Gnus/5.090008 (Oort Gnus v0.08) XEmacs/21.4 (Honest Recruiter, sparc-sun-solaris2.6) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-SW-Source: 2002-09/txt/msg01222.txt.bz2 Robert Dewar writes: > By the way it certainly seems that YACC is incorrect here in its > approach, and at the very least should discuss the implications of its > choice for YYSTYPE. A simple define of YYSTYPE to a single C type is only appropriate for very simple parsers where all tokens return the same type data. Any more complex parser should use the %union directive, which declares YYSTYPE as a union type. This is stated in the bison manual, although not in precisely that way (instead, the bison manual shows using %union everywhere and only mentions in one side page that for very simple parsers you can define YYSTYPE instad). By using a simple YYSTYPE when YYSTYPE is actually storing multiple different data types, you're lying to the compiler, and it's unsurprising that things break. It's not portable, may not work at all on platforms where pointers can not be stored safely in integral types, requires unnecessary casts, and destroys what type checking the C compiler is able to do, even apart from the aliasing concerns. -- Russ Allbery (rra@stanford.edu)