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

            Bug ID: 63350
           Summary: LTO error: error: inlining failed in call to
                    always_inline 'f': function body not available
           Product: gcc
           Version: 4.9.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: lto
          Assignee: unassigned at gcc dot gnu.org
          Reporter: vic100 at mail dot com

If I don't use LTO then the main loop is optimized out. If I use LTO with
inline INLINE keywords then it's a linker error. If I use LTO without inline
INLINE keywords then it links but the main loop is not optimized out. If I use
LTO with only the INLINE keyword then it doesn't link, I get "error: inlining
failed in call to always_inline 'f': mismatched arguments." If I use LTO with
only the inline keyword I get "undefined reference to `scalar::f(scalar)'."


//contents of main.cpp : 
#include "O.h"
int main()
{
for (int i = 0; i<2000000000; i++)
    {scalar test; test.f(9);}
return 0;
}


//contents of O.h :
#define INLINE __attribute__((always_inline))
class scalar
    {
    private:
        float u;
    public:
        scalar();
        scalar(const scalar &);
        scalar(float);
        inline INLINE void f(scalar);
    };

//contents of O.cpp :
#include "O.h"
scalar::scalar() : u(0) {}
scalar::scalar(const scalar &rhs) : u(rhs.u) {}
scalar::scalar(float rhs) : u(rhs) {}
inline INLINE void scalar::f(scalar sc) {u = sc.u;}
----------------------------------------------------

-------------- Build: Debug in E (compiler: mingw-w64)---------------

g++.exe -O3 -flto -ffat-lto-objects  -c C:\CodeBlocks\main.cpp -o
obj\Debug\main.o
In file included from C:\CodeBlocks\main.cpp:1:0:
C:\CodeBlocks\O.h:10:28: warning: inline function 'void scalar::f(scalar)' used
but never defined
         inline INLINE void f(scalar);
                            ^
g++.exe -O3 -flto -ffat-lto-objects  -c C:\CodeBlocks\O.cpp -o obj\Debug\O.o
g++.exe  -o bin\Debug\E.exe obj\Debug\main.o obj\Debug\O.o  -O3 -flto
-ffat-lto-objects  
C:\CodeBlocks\main.cpp: In function 'main':
C:\CodeBlocks\O.h:10:28: error: inlining failed in call to always_inline 'f':
function body not available
         inline INLINE void f(scalar);
                            ^
C:\CodeBlocks\main.cpp:5:28: error: called from here
     {scalar test; test.f(9);}
                            ^
lto-wrapper: g++.exe returned 1 exit status
C:/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/4.9.1/../../../../x86_64-w64-mingw32/bin/ld.exe:
lto-wrapper failed
collect2.exe: error: ld returned 1 exit status
Process terminated with status 1 (0 minute(s), 0 second(s))
2 error(s), 1 warning(s) (0 minute(s), 0 second(s))
--------------------------------------------------------

Reply via email to