On Nov 13, 2007 12:14 AM, Gabriel Sechan <[EMAIL PROTECTED]> wrote:
>
>
> ----------------------------------------
> > Date: Tue, 13 Nov 2007 00:01:55 -0800
> > From: [EMAIL PROTECTED]
> > To: [email protected]
> > Subject: Re: gcc optimizes out program ID string
> >
> > On Nov 12, 2007 11:15 PM, Gabriel Sechan  wrote:
> >>
> >> I don't think so.  I expect unused variables to be optimized out.  All of 
> >> them.  That's the least surprising thing to do, since they aren't needed.  
> >> Why keep this one special one around, for some odd use case that I don't 
> >> quite get.
> >
> > Let me try to explain the odd-use case so that you can get it.
> >
> > One wants to plant a marker inside an object file that can be easily
> > retrieved to indicate the particular source file that produced that
> > object file.  The same marker should be propagated to the executable
> > file that may be a combination of several object files.
> >
> > Until gcc4  this could be done in a simple manner that even I could
> > remember.  There are standard tools to retrieve the marker(s) from the
> > object file or the executable.  They work with standard tools to plant
> > the original marker in the source file.
> >
> > Got it yet?
> >
> Not sure I see the value of it, but I understand it.  They still made the 
> right decision-  unused variables should be optimized out.  Preferably with a 
> warning.  This would need to be special cased, and I can easily see why they 
> don't want to do that-  special cases lead to bugs, they should only be used 
> when necessary.  Since there's workarounds here, there's no reason to do so.  
> Its not like that variable has special meaning under the C standard.  Sorry 
> it makes more work for you, but its the right technical decision.

Well, then let me object to the lack of warning.  Unless I am supposed
to turn on more warning flags in gcc.  Suppose I should try this, to
see if I ever get warned.

By the way, reading the  "gcc at gcc dot gnu dot org " mailing list I
see that I am  not the only one who has used embedded strings for
tagging compiled files so they can be traced back to their sources, or
for other identification purposes.

More work for me means that I have to remember __attribute__((unused))
to defeat this particular "optimization".  It also means that I spent
an hour or two wondering why things that used to work no longer do.
Charge it up to education.

    carl
-- 
    carl lowenstein         marine physical lab     u.c. san diego
                                                 [EMAIL PROTECTED]

-- 
[email protected]
http://www.kernel-panic.org/cgi-bin/mailman/listinfo/kplug-lpsg

Reply via email to