-
Notifications
You must be signed in to change notification settings - Fork 4.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Modify the condition of SPDLOG_CONSTEXPR_FUNC to match that of fmt #2858
Conversation
…ndled fmt FMT_USE_CONSTEXPR * fix the issue where constexpr function in spdlog may call non-constexpr function in the bundled fmt because FMT_USE_CONSTEXPR is not defined
Thanks, however thats way too much additions and new macros for this simple fix. |
I was hoping to match the condition in fmt for ease of maintenance in the future. Would you prefer a simpler condition for the SPDLOG_CONSTEXPR_FUNC macro or marking the affected function as inline instead? |
Since this is nvcc specific, simple ifdef nvcc is sufficient. |
I believe this will affect other compilers too. The compile time error will happen whenever SPDLOG_CONSTEXPR_FUNC is defined but FMT_USE_CONSTEXPR is not. The FMT_USE_CONSTEXPR condition in the bundled fmt is the following: # if (FMT_HAS_FEATURE(cxx_relaxed_constexpr) || FMT_MSC_VERSION >= 1912 || \
(FMT_GCC_VERSION >= 600 && FMT_CPLUSPLUS >= 201402L)) && \
!FMT_ICC_VERSION && !defined(__NVCC__) The issue is also very visible because it happens on any kind of logging as simple as If you believe |
So how come it is not a common problem and wasn't reported many times so far? |
I guess the condition is rather hard to meet and some compilers do not raise an error in some cases. However, I'm able to verify that the same issue happens on gcc-5 with the following source file: #include "spdlog/spdlog.h"
int main(int argc, char **argv)
{
spdlog::info("info");
return 0;
}
Some versions of ICC (which is another corner case in the FMT_CONSTEXPR condition) allows constexpr functions to call non-constexpr functions (as shown in this example). I have verified that spdlog compiles with the latest ICC. I'm not able to test on MSVC. |
I don't mimd a minimal fix, with minimal or no new macros. sodlog defines too many macros already imo. |
fix #2856