bison-patches
[Top][All Lists]
Advanced

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

Re: IF_LINT is dangerous (Was: Re: Version 2.5_rc1 gcc issues)


From: Paul Eggert
Subject: Re: IF_LINT is dangerous (Was: Re: Version 2.5_rc1 gcc issues)
Date: Sun, 01 May 2011 22:12:36 -0700
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.14) Gecko/20110223 Thunderbird/3.1.8

On 05/01/11 20:45, Joel E. Denny wrote:

> I don't understand the benefit of suppressing initializations.  If 
> the point is to document that the initialization isn't intended to be 
> important to the logic of the program, then a comment saying so is 
> sufficient.

It depends on how important efficiency is.  If it's not important,
a comment should suffice.  If it is, then leaving the initialization
in causes compilers to generate worse code.

> in the IF_LINT cases, compiles 
> with possibly less warnings and that runs with different and possibly 
> safer logic than the Bison the user compiles and runs

Although that is a problem, in practice it's minor.

> If there are no objections, I will soon replace all uses of IF_LINT with 
> the code it encloses.

Please leave the gnulib IF_LINTs alone; they're used in programs
where efficiency is considered important.  For Bison code where efficiency
doesn't matter that much, you might consider putting something
like this into system.h:

  /* Use this when the actual value X doesn't matter, but something
     needs to be present to pacify compilers that would otherwise warn
     about possibly-uninitialized variables.  */
  #define DONT_CARE(x) (x)

and then initializers that exist merely to pacify GCC can be
written like this:

  location id_loc = DONT_CARE (empty_location);

That way, you won't need a special comment next to every such
initializer.



reply via email to

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