#1 unnecessary symbols in output

closed-wont-fix
nobody
None
5
2004-09-06
2003-11-26
Alex Butler
No

bcc will force the compiler to add symbols into the
assembly that should not be there.

see the following code example:
/*****************************************************/
extern int aglobal;
static inline void testfun(void)
{
aglobal = 4;
return;
}
/*****************************************************/

If the above code is compiled with -fbounds-checking
the asm will contain a reference to aglobal which gcc
normally would take out. gcc reserves removal of
inline and other external symbols until the near end of
the compilation phase.

bcc calls bounds_build_static_constructors() too early
before the compiler actually takes out these
unnecessary symbols.

optimization has no effect.

trace of gcc compilation
toplev_main()
do_compile()
compile_file()
+c_common_parse_file() c-lex.c:147
| yyparse() c-parse.c:2057
| finish_file() c-lang.c:215
| c_objc_common_finish_file()
c-objc-common.c:359
| bounds_build_static_constructors()
| bounds_external_declaration (vec,len)
| bounds_assemble_private_statics_table()
| declare_private_statics()
|
+write_global_declarations()
wrapup_global_declarations()

Alex

Discussion

  • Logged In: YES
    user_id=844843

    This was done on purpose. We want to know as much as
    possible about externel variables. This is why we put it in
    the __bounds_private_statics tabel. This makes it possible
    the compile one file with bounds-checking and another not.
    If we see externs in the one compiled with bounds-checking
    we know the size and this helps us finding errors.
    I think the c-standard allows this behaviour.
    I you really want this behaviour you could write your code as:

    static inline void testfun(void)
    {
    extern int aglobal;
    aglobal = 4;
    return;
    }

     
    • status: open --> closed-wont-fix