Newer gcc swallow version control keywords

Newer gcc swallow version control keywords

Oleg Goldshmidt pub at goldshmidt.org
Mon Oct 17 22:21:43 IST 2011


"Nadav Har'El" <nyh at math.technion.ac.il> writes:

> In any case, because there was always a fear that the compiler might
> optimize these out, someone invented a new directive, #ident, as in:
>
> #ident "$Id$"

This has always been there, but it has never been standard, AFAIK. It
is not a GCC extension, either. Most preprocessors don't barf on
directives they do not understand, but they may simply ignore #ident
which will lead to the same behaviour that I do not want.

When you say that it has worked for you with all sorts of compilers do
you mean that it actually produced the $Id$ string with ident or that
it didn't break? 

> Why is this incredebly ugly?

Because #including an extra header just for this purpose _is_ ugly,
IMHO (compared to just compiling with an extra option).

> Apparently, the optimizer behavior you're reporting and the odd behavior of
> -fkeep-static-consts you report is NOT new. Check out this bug report
> from 6 (!) years ago:
>
> 	http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20319

I was wondering whether someone would catch my little mischief: this
bug report complains about the same effect in a slightly different
situation. Even with older GCC the $Id$ string is not there with just
-O2, but it is with "-g -O2" (cf. my original posting - I put the
exact command line there for a reason). 

Yes, I agree with the opinion that -fkeep-static-consts should
override optimization (it is more specific), but it has never been the
case (or at least not for a very long time).

Thanks,

-- 
Oleg Goldshmidt | pub at goldshmidt.org



More information about the Linux-il mailing list