You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have come across an issue where two test cases in separate source files, that happen to acquire the same name (due to COUNTER macro being per compilation unit), and using lambdas inside them are compiled (or linked) incorrectly. The issue is certainly in either gcc or the linker (or both) and relates to how it handles inline functions.
In this particular case the issue is in macro DOCTEST_CREATE_AND_REGISTER_FUNCTION. It forwards declares the function as static, and then implements it as inline, but without "static". The fix is in either defining the function as static inline, or just forget about inline (after all the name is going ot be unique within a compilation unit, inline seems unnecessary here).
I have managed to reproduce the compiler(or linker) bug without doctest, I can supply more details if interested. But in this particular case, when two modules declare static functions of the same name, and then define them as inline without "static", and also both declare and call a lambda inside, both functions will end up calling the same lambda (from one of the functions, the other one will not be in the executable at all).
I can create and submit a PR with a fix, but it is as simple as changing
inline void f()
to either
static inline void f()
or
static void f()
This is line 1188 in the latest version at the time of writing.
The text was updated successfully, but these errors were encountered:
Apparently, the issue is not about Linux Vs MinGW, etc (I'm compiling under
cygwin64). It's a bug that was present in gcc 5.4, but was fixed in 6.1. At
least so I've been told, haven't verified myself yet. But the fix that
you've now committed ensures that it won't hit the bug even for 5.4.
Regards,
Konstantin
I have come across an issue where two test cases in separate source files, that happen to acquire the same name (due to COUNTER macro being per compilation unit), and using lambdas inside them are compiled (or linked) incorrectly. The issue is certainly in either gcc or the linker (or both) and relates to how it handles inline functions.
In this particular case the issue is in macro DOCTEST_CREATE_AND_REGISTER_FUNCTION. It forwards declares the function as static, and then implements it as inline, but without "static". The fix is in either defining the function as static inline, or just forget about inline (after all the name is going ot be unique within a compilation unit, inline seems unnecessary here).
I have managed to reproduce the compiler(or linker) bug without doctest, I can supply more details if interested. But in this particular case, when two modules declare static functions of the same name, and then define them as inline without "static", and also both declare and call a lambda inside, both functions will end up calling the same lambda (from one of the functions, the other one will not be in the executable at all).
I can create and submit a PR with a fix, but it is as simple as changing
inline void f()
to either
static inline void f()
or
static void f()
This is line 1188 in the latest version at the time of writing.
The text was updated successfully, but these errors were encountered: