[Bug preprocessor/77488] Proposal for __FILENAME_ONLY__

jakub at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Tue Sep 6 17:23:00 GMT 2016


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77488

--- Comment #4 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
(In reply to Martin Sebor from comment #3)
> Perhaps it might be possible to generalize the enhancement request to a
> space optimization for GCC to store only the trailing part of strings that
> are ever referenced in the program.  For instance, since in the file below
> only the range [s + 5, s + 10] is ever used it should be possible to store
> just "56789" instead of all of "0123456789" (this would only be possible if
> all computations involving the literal were known and would have to be
> avoided if a pointer to the literal escaped to an external function that
> could derive from it a pointer to the initial substring).
> 
> static const char* const s = "0123456789" + 5;
> 
> void f (void)
> {
>   __builtin_printf ("%s\n", s);
> }

How would that help here?  You obviously pass the address of the string literal
to the __assert_func or how is the assertion passed, thus it escapes.

Though, especially when using autoconf/automake, it really is very easy, not
hard, to tweak the Makefiles to use short paths.  And, in many cases, the
basename of source files isn't unique and sufficient to recognize where the
problem is.  E.g. glibc ships with tons of headers like <string.h>,
<bits/string.h>, <elf.h>, <sys/elf.h> etc.


More information about the Gcc-bugs mailing list