Menu

Error: inlining failed in call to test::~test

yhw
2013-02-18
2013-06-06
  • yhw

    yhw - 2013-02-18

    Using x86_64-w64-mingw32-gcc-4.7.2-release-win64_rubenvb.7z on Windows 7 x64.

    I compile my C++ program with both -Winline and -Werror flags enabled because I highly rely on inlining and want to manually control it. If gcc can't inline some functions, I get a error message, increase various inline related limits and compile again until all functions that I marked as "inline" are actually inlined. But sometimes I get strange error messages. Try this code for example:

    #include <string>
    struct test {
        test(int, char **) { }
        std::string a;
        std::string b;
    };
    int main(int argc, char **argv) {
        test t(argc, argv);
        return 0;
    }
    
    > g++ -O2 -Wall -Wextra -Werror -Winline -std=c++11 test.cpp -o test.exe
    test.cpp: In function 'int main(int, char**)':
    test.cpp:3:8: error: inlining failed in call to 'test::~test() noexcept (true)': call is unlikely and code size would grow [-Werror=inline]
    test.cpp:13:10: error: called from here [-Werror=inline]
    cc1plus.exe: all warnings being treated as errors
    

    As you can see, the class test has no explicitly defined destructor. So I don't care if gcc is unable to inline it. Moreover, if I define the destructor like this

    struct test {
        test(int, char **) { }
        ~test() { }
        std::string a;
        std::string b;
    };
    

    gcc compiles it without any warnings despite the fact that the destructor is still implicitly inline.

    I'm not sure if this is a mingw or gcc bug. Maybe std::string is somehow related to it. Any ideas?

     
  • yhw

    yhw - 2013-02-18

    Tried x86_64-w64-mingw32-gcc-4.8-unstable-win64_rubenvb.7z, the warning is not shown there. But I can't compile boost with it, so it's useless for me so far.

     

Log in to post a comment.