Is this a GCC bug?

When compiling my mix of C and C++ projects, I get this error strongly (this is when compiling a C ++ file):

 /usr/include/c++/4.6/x86_64-linux-gnu/./bits/c++locale.h: In function 'int std::__convert_from_v(__locale_struct* const&, char*, int, const char*, ...)': /usr/include/c++/4.6/x86_64-linux-gnu/./bits/c++locale.h:70:3: sorry, unimplemented: function 'int std::__convert_from_v(__locale_struct* const&, char*, int, const char*, ...)' can never be inlined because it uses variable argument lists 

And the compilation is completed.

But when I manually edited the file /usr/include/c++/4.6/x86_64-linux-gnu/./bits/c++locale.h and remove the inline modifier before __convert_from_v it WORKS .

The problem causing the source code problems is related to inline initially:

 inline int __convert_from_v(const __c_locale& __cloc __attribute__ ((__unused__)), char* __out, const int __size __attribute__ ((__unused__)), const char* __fmt, ...) 

I think a function like this MUST NOT be marked as inline . Is this a mistake or am I doing something wrong ??? [gcc 4.6.1, Ubuntu 11.10]

+4
source share
2 answers

This is likely due to optimization settings or inline overrides that force __convert_from_v be forced. Here is a small artificial example that reproduces the error:

 #define inline __always_inline #include <bits/c++locale.h> int main () { __locale_t loc; return std::__convert_from_v(loc, 0, 0, 0); } 

Compiling with g ++ 4.6.1 on Ubuntu 11.10 gives an error:

 /usr/include/c++/4.6/x86_64-linux-gnu/./bits/c++locale.h: In function 'int std::__convert_from_v(__locale_struct* const&, char*, int, const char*, ...)': /usr/include/c++/4.6/x86_64-linux-gnu/./bits/c++locale.h:70:3: sorry, unimplemented: function 'int std::__convert_from_v(__locale_struct* const&, char*, int, const char*, ...)' can never be inlined because it uses variable argument lists 

So check the code to override inline or try various optimization settings.

I think the reason this function is marked as inline is because it is defined in the header. Without inline you would define it in every translation unit that includes (usually indirectly) this header.

+7
source

C to C99 does not have a keyword embedded . Check your compiler configuration.

0
source

Source: https://habr.com/ru/post/1385963/


All Articles