This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

ARM Compiler 6.7: bug in size optimization?

Source of main.cpp:

typedef void (* fun_t)( void );

static const fun_t fun = [] { for (;;); };

int main( void )
{
        fun();
}


Listing:

...
    Region$$Table$$Base
    Region$$Table$$Limit
    main

** Section #2 '.debug_frame' (SHT_PROGBITS)
    Size   : 68 bytes
...


Map file:

...
    Removing main.o(.text), (0 bytes).
    Removing main.o(.ARM.exidx.text.main), (8 bytes).
    Removing main.o(.ARM.use_no_argv), (4 bytes).
...


Why main function was removed?

Parents
  • Code

    typedef void (* fun_t)( void );
    
    static const fun_t fun = [] { for (;;); };
    
    int main( void )
    {
        fun();
    }
    


    is equivalent to the code below

    int main( void )
    {
        for (;;);
    }
    


    So I think that main function has not dead code, it has infinite loop.
    The second version is compiled correctly.

        main
            0x08000230:    e7fe        ..      B        main ; 0x8000230
            0x08000232:    0000        ..      MOVS     r0,r0
    


    Is it bug of the compiler?

Reply
  • Code

    typedef void (* fun_t)( void );
    
    static const fun_t fun = [] { for (;;); };
    
    int main( void )
    {
        fun();
    }
    


    is equivalent to the code below

    int main( void )
    {
        for (;;);
    }
    


    So I think that main function has not dead code, it has infinite loop.
    The second version is compiled correctly.

        main
            0x08000230:    e7fe        ..      B        main ; 0x8000230
            0x08000232:    0000        ..      MOVS     r0,r0
    


    Is it bug of the compiler?

Children