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

Fix -Wconversion warning #2724

Merged
merged 2 commits into from
Jan 19, 2022
Merged

Fix -Wconversion warning #2724

merged 2 commits into from
Jan 19, 2022

Conversation

Tobi823
Copy link
Contributor

@Tobi823 Tobi823 commented Jan 18, 2022

Thanks for your great work and the great fmt library.

I have a small problem. When I cross-compile (with dockcross/linux-armv7 https://github.com/dockcross/dockcross to Raspberry Pi ARMv7) my source code with your fmt-library, I receive this warning:

/work/build_armv7/_deps/fmt-src/include/fmt/chrono.h:1217:37: warning: conversion from 'std::make_unsigned<long long int>::type' {aka 'long long unsigned int'} to 'size_t' {aka 'unsigned int'} may change value [-Wconversion]
 1217 |       copy2(buf, digits2(to_unsigned(year / 100)));
      |                          ~~~~~~~~~~~^~~~~~~~~~~~

Not using the -Wconversion flag is not an option because I want to use the flag to detect as many errors as possible.
And I'm not able to configure CMake, CPMAddPackage and target_include_directories+SYSTEM correctly to ignore warnings from your library 🙈.

My solution (adding const_cast<size_t>) works for me but I don't know if this is a clean solution. I'm not a C++ expert.

…'std::make_unsigned<long long int>::type' {aka 'long long unsigned int'} to 'size_t' {aka 'unsigned int'} may change value [-Wconversion]" by casting int to size_t (occurs when cross-compiling to Raspberry Pi ARMv7)
Copy link
Contributor

@vitaut vitaut left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR.

include/fmt/chrono.h Outdated Show resolved Hide resolved
@vitaut vitaut merged commit b8b037e into fmtlib:master Jan 19, 2022
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

Successfully merging this pull request may close these issues.

None yet

3 participants