-
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
test/compile-test.cc:339:21: error: consteval function 'test_format not a constant expression. #2205
Comments
Fixed in 7c43f8b. Thanks for reporting. |
I have re-downloaded
|
It seems "
[LIVE] |
I was not able to repro the issue. clang's trunk compiles this correctly (https://compiler-explorer.com/z/71s4G3aW8): #include <fmt/compile.h>
template <size_t max_string_length, typename Char = char> struct test_string {
template <typename T> constexpr bool operator==(const T& rhs) const noexcept {
return fmt::basic_string_view<Char>(rhs).compare(buffer.data()) == 0;
}
std::array<Char, max_string_length> buffer{};
};
template <size_t max_string_length, typename Char = char, typename... Args>
consteval auto test_format(auto format, const Args&... args) {
test_string<max_string_length, Char> string{};
fmt::format_to(string.buffer.data(), format, args...);
return string;
}
int main() {
constexpr auto s = test_format<6>(FMT_COMPILE("{:5}"), true);
} Note that the latest released version of clang is 11 so you are probably using a development version. |
This is output of clang 12.
|
This is output of clang 11.
|
This is output of clang 11.
|
I'm not sure why clang 11 complains about gmock duplicated symbols while clang 12 doesn't.
|
Do you have a godbolt repro? |
I still have no clues to create CE repro. GCC 10.2 and 11.0.1 can cmake it through. Still, this seems not to related with my clang issue.
|
Repro on Compiler Explorer with Clang 11 (but trunk also fails): https://compiler-explorer.com/z/oWfGGrGs3 |
But I don't understand why |
Good idea, a PR is welcome =). |
Reopening since there is also a portability issue in precision test:
|
I think that error in #include <cstdio>
int main() { printf("%.*A\n", 838, -2.14001164E+38); } should also print an incorrect result |
The values are equal so maybe all we need is to relax this test. |
[LIVE]
However why on earth does the compiler "have the right" to shift the dot to the right at the 1st place ?! |
I'm not sure but I worked around the hexfloat issue in 5a8bf1f. Thanks for reporting. |
From C (not C++, don't think they differ) standard (draft, actually) about
So there is no guarantee that the first digit will be Maybe it will be more portable to use |
|
In test-enabled cmake, I got this error
compiler: clang 12 from https://llvm.org/builds/ in
--target=x86_64-w64-windows-gnu
modeAny ideas?
The text was updated successfully, but these errors were encountered: