This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: gcc 4.0.0 optimization vs. id strings (RCS, SCCS, etc.)


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Bruce Lilly wrote:
> Hi,
> 
> Earlier versions of gcc retain static character strings in object files
> which can be used for identification via ident (RCS) or what (SCCS).
> Gcc 4.0.0 removes them above optimization level 1.  Global strings
> are retained, of course, but that may lead to namespace collisions.
> #ident doesn't work on some architectures, and functionality can't
> be determined at preprocessor time.  #sccs doesn't work at all.  The
> bottom line is that identification which worked with earlier versions
> of gcc is broken under 4.0.0.  See attached C source code example.
> 
> 
> ------------------------------------------------------------------------
> 
> /* the following works with SCCS (what) and RCS et al (ident) with gcc 3.x and
>       earlier 
>    string symbol is local (static) to object file and does not clash
>       with symbols similarly defined in other files in the same package
>       or in library archives used with a package
>    gcc 4.0.0 with optimization level 2 or greater elides the symbol and string,
>       breaking identification; -fkeep-static-consts is ineffective with
>       optimization turned on
> */
> static const char rcs_sccs_id[] =
>     "$Id: @(#)%M% %I% 20%E% %U% copyright 2005 %Q% string1\\ $";

Use
static const char rcs_sccs_id[] __attribute__((used)) = ".."

Sebastian
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iQEVAwUBQm2Md/81M8QtvOSJAQKPxgf+N6Q6iKedLaWOwrYRcC2rrDo2/iqDTc36
aIlIJQN5I41T8JRt0R0T5vnxRdTGx6v2VIpYf6Xw/wMigbA22ANUhp/r6DnYaJS0
ieKzyEf4BPlL3xuMfhIU7UzUI3ogzF8lsFhiAgtvm/1bu1IeFIUevlyfj57ZfV7H
2Vl3CuQ8SFLBLj+k6FJV1svcCnzo52msvBggZwvLRd9CizpDaJ41cyeH+StFNaXo
BQRQYnsoZhbhvCFGSCmHOKdaMB10XE1R6QNL86f/YYEDrX/slY4Kxc1pr4heBC/M
FLY1hnj1+MPK0Ch5HyAzLlMNDBG9gUR8MvY9UCIEXonpt6QspjWKXg==
=jy0E
-----END PGP SIGNATURE-----


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]