cc1plus emits __FUNCTION__ etc even if unreferenced

Zack Weinberg zack@wolery.cumb.org
Mon Jun 19 13:48:00 GMT 2000


$ ./cc1plus -quiet -fno-ident </dev/null
        .file   "stdin"
        .version        "01.01"
gcc2_compiled.:
                .section        .rodata
        .type    __FUNCTION__,@object
        .size    __FUNCTION__,1
__FUNCTION__:
        .string ""
        .type    __PRETTY_FUNCTION__,@object
        .size    __PRETTY_FUNCTION__,10
__PRETTY_FUNCTION__:
        .string "top level"
        .type    __func__,@object
        .size    __func__,1
__func__:
        .string ""
$

Compare what you get from cc1:

$ ./cc1 -quiet -fno-ident </dev/null
        .file   "stdin"
        .version        "01.01"
gcc2_compiled.:
$

If you run them through the assembler, the C++ object file is ~200
bytes bigger (x86, ELF).

There's some code in cp/decl.c that wants to prevent this:

      /* Pretend we've output an unused static variable.  This ensures
         that the toplevel __FUNCTION__ etc won't be emitted, unless
         needed. */

(in wrapup_globals_for_namespace) but it apparently doesn't work.

zw


More information about the Gcc-bugs mailing list