-
Notifications
You must be signed in to change notification settings - Fork 2.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
Compile error for runtime strings #2536
Comments
What compiler version and flags do you use? Could you provide a godbolt repro? |
I never noticed an actual compiler error for this, but I had noticed Intellisense complaining about it. Since it was only a nuisance error listed in the Error List window as I never use the UDLs, I didn't bother reporting it. I think ICC is the only EDG-based compiler that is on godbolt, but it's using an older version than Microsoft https://gcc.godbolt.org/z/Pdo443dsn (smaller It may be enough to add a condition of Full repro output for VS2019 and VS2022:
And it's not an issue for the normal compiler:
EDG / Intellisense may not even fully implement non-type template parameters and static_assert(__cpp_nontype_template_args >= 201911L, "just to get rid of #if's later on");
#ifndef BYPASS_EDG_CHECK
static_assert(__EDG__);
static_assert(__EDG_VERSION__ == 602);
#endif
using size_t = decltype(sizeof(0));
namespace detail_exported {
template <typename Char, size_t N> struct fixed_string {
constexpr fixed_string(const Char (&)[N]) {
}
Char data[N]{};
};
}
template <detail_exported::fixed_string Str>
constexpr auto test_it() -> int {
return 5;
}
static_assert(test_it<"1">() == 5);
|
Thanks @mwinterb for investigating. A PR to add |
I replaced all lines #if FMT_USE_NONTYPE_TEMPLATE_PARAMETERS with #if FMT_USE_NONTYPE_TEMPLATE_PARAMETERS && !defined(__INTELLISENSE__) and that takes care of all the issues. |
Closing since this is a bug in intellisense. Please report to Microsoft. |
When change "#if FMT_USE_NONTYPE_TEMPLATE_PARAMETERS" to "#if FMT_USE_NONTYPE_TEMPLATE_PARAMETERS && !defined(INTELLISENSE)" , it's show another error : |
@vitaut are you sure about that? Maybe I'm misunderstanding what that template is actually doing, but it seems like it isn't following the standard and that's why intellisense is listing the error. |
Yes, I'm sure. That answer is very out of date. |
I am incorporating the fmt library in my project using CMake and link it as a public library.
When I build a C++ project targeted at Visual Studio platform, it's compiler and intellisense complain about this line of code
which returns this error:
The C++ compiler version I am using is C++20. I am not passing any special flags to the compiler.
What do I have to do to fix this error?
The text was updated successfully, but these errors were encountered: