Skip to content
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

Warnings from {fmt} when using xchar.h header and -fsigned-char flag on ARM #2400

Closed
alexezeder opened this issue Jun 28, 2021 · 2 comments
Closed

Comments

@alexezeder
Copy link
Contributor

On the latest {fmt} version (8.0, master) I get these warnings just by including {fmt} headers (https://godbolt.org/z/arEYeq9rx):

/fmt/trunk/include/fmt/format.h:1026:17: warning: comparison of integer expressions of different signedness: 'const wchar_t' and 'const char' [-Wsign-compare]
 1026 |   return lhs[0] == rhs[0] && lhs[1] == rhs[1];
      |          ~~~~~~~^~~~~~~~~
...
/fmt/trunk/include/fmt/core.h:2092:14: warning: comparison of integer expressions of different signedness: 'const wchar_t' and 'char' [-Wsign-compare]
 2092 |     if (*out == value) return true;
      |         ~~~~~^~~~~~~~

from here:

fmt/include/fmt/format.h

Lines 1025 to 1027 in c3c27e5

template <typename Char> auto equal2(const Char* lhs, const char* rhs) -> bool {
return lhs[0] == rhs[0] && lhs[1] == rhs[1];
}

fmt/include/fmt/core.h

Lines 2088 to 2095 in c3c27e5

// Return the result via the out param to workaround gcc bug 77539.
template <bool IS_CONSTEXPR, typename T, typename Ptr = const T*>
FMT_CONSTEXPR auto find(Ptr first, Ptr last, T value, Ptr& out) -> bool {
for (out = first; out != last; ++out) {
if (*out == value) return true;
}
return false;
}

These warnings are pretty logical since the signedness of char-types (char and wchar_t) is different in this case - https://godbolt.org/z/1Pdxbesvf.

Still, there are no warnings with {fmt} 7.1.3 - https://godbolt.org/z/T1qPjfoaG.

I'm not familiar with that part of the library, so maybe someone can find the cause of this regression in few seconds, for example, @vitaut 😉

@vitaut
Copy link
Contributor

vitaut commented Jun 30, 2021

It's unclear why there were no warnings in 7.1.3 but I fixed them in 785908e. Thanks for reporting.

@vitaut vitaut closed this as completed Jun 30, 2021
@alexezeder
Copy link
Contributor Author

Thank you for fixing this!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants