On Sun, Apr 1, 2018 at 7:34 AM, Jason Vas Dias <jason.vas.d...@gmail.com> wrote:
> And even worse, the obvious workaround does not work:
>
>     static inline __attribute__((always_inline))
>     void foo(void) {}
>
> //  static inline __attribute__((always_inline, alias("foo")))
> //  void bar(void);
>
>     static inline __attribute__((always_inline))
>     void (&bar)(void) = foo;
>
>    void f(void)
>    { bar();
>    }

> So one has to do just
>     static
>     void (&bar) ( void ) = foo;
>
> So now foo() has lost its inline-ness:
>
> $ nm -C t.o
> 0000000000000007 T f()
> 0000000000000000 r bar
> 0000000000000000 t foo()

That's a missed-optimization bug, the compiler should be able to see
through the reference and inline foo().  But it probably won't be
fixed for GCC 8.

> ie. the compiler did not warn that foo
> has been made into an ordinary symbol:
>
> '
>     $ cat t.c
>     static inline __attribute__((always_inline))
>     void foo(void) {}
>     static
>     void (&bar)(void) = foo;
>     void f(void){ bar();}
>     $ g++ -std=gnu++11 -x c++ -Wall -Wextra -c t.c
>     $
>  '
> I think g++ should have warned that it is not treating
> an always inline function as inline here !

Yes, we should probably warn about emitting an always_inline function.

Jason

Reply via email to