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

-Wconversion warnings on GCC #1215

Open
SimonMaracine opened this issue Jan 31, 2025 · 4 comments
Open

-Wconversion warnings on GCC #1215

SimonMaracine opened this issue Jan 31, 2025 · 4 comments
Assignees
Labels
enhancement accepted requests, sooner or later I'll do it

Comments

@SimonMaracine
Copy link

SimonMaracine commented Jan 31, 2025

Hello!

I'm using EnTT in my project, on which I have set up -Wall -Wextra -Wpedantic -Wconversion as usual. But due to EnTT being a header only library, those flags apply to EnTT code as well.

For quite a while I have already silenced those warnings that EnTT emitted in the code directly (being the only solution AFAIK):

#ifdef __GNUG__
    #pragma GCC diagnostic push
    #pragma GCC diagnostic ignored "-Wconversion"
#endif

#include <entt/signal/dispatcher.hpp>

#ifdef __GNUG__
    #pragma GCC diagnostic pop
#endif

But it's a bit annoying to do that in all places.

Recently, then, I updated the submodule and got some more warnings from EnTT.

It might be bold, but I want to propose to enable -Wconversion in all (test, example) targets built by EnTT and to fix the warnings in the code. You might not want that and I understand, I'll not be upset. :) I just think it might be a good idea. (Once a conversion warning saved me from a bug!)

/home/simon/PROJECTS/SOME_PROJECT/extern/entt/src/entt/signal/../container/dense_map.hpp:340:34: warning: conversion from ‘entt::dense_map<unsigned int, std::shared_ptr<entt::internal::basic_dispatcher_handler>, entt::identity, std::equal_to<void>, std::allocator<std::pair<const unsigned int, std::shared_ptr<entt::internal::basic_dispatcher_handler> > > >::size_type’ {aka ‘long unsigned int’} to ‘float’ may change value [-Wconversion]
  340 |         if(size() > (bucket_count() * max_load_factor())) {
      |                      ~~~~~~~~~~~~^~
/home/simon/PROJECTS/SOME_PROJECT/extern/entt/src/entt/signal/../container/dense_map.hpp:340:16: warning: conversion from ‘entt::dense_map<unsigned int, std::shared_ptr<entt::internal::basic_dispatcher_handler>, entt::identity, std::equal_to<void>, std::allocator<std::pair<const unsigned int, std::shared_ptr<entt::internal::basic_dispatcher_handler> > > >::size_type’ {aka ‘long unsigned int’} to ‘float’ may change value [-Wconversion]
  340 |         if(size() > (bucket_count() * max_load_factor())) {
      |            ~~~~^~
/home/simon/PROJECTS/SOME_PROJECT/extern/entt/src/entt/signal/../container/dense_map.hpp:983:53: warning: conversion from ‘entt::dense_map<unsigned int, std::shared_ptr<entt::internal::basic_dispatcher_handler>, entt::identity, std::equal_to<void>, std::allocator<std::pair<const unsigned int, std::shared_ptr<entt::internal::basic_dispatcher_handler> > > >::size_type’ {aka ‘long unsigned int’} to ‘float’ may change value [-Wconversion]
  983 |         const auto cap = static_cast<size_type>(size() / max_load_factor());
      |                                                 ~~~~^~
``
@skypjack skypjack self-assigned this Jan 31, 2025
@skypjack skypjack added the triage pending issue, PR or whatever label Jan 31, 2025
@skypjack
Copy link
Owner

How many conversion warnings are there?

@SimonMaracine
Copy link
Author

I use only one or two parts of the EnTT library, so there are only three parts of the code that generate conversion warnings (the ones above). But during build, those are being emitted multiple times, printing relatively large blocks of text.

@skypjack
Copy link
Owner

skypjack commented Feb 4, 2025

Anything related to -Wextra instead? I don't use it on the CI either.

@SimonMaracine
Copy link
Author

No, I don't see any other warnings coming from EnTT.

@skypjack skypjack added enhancement accepted requests, sooner or later I'll do it and removed triage pending issue, PR or whatever labels Feb 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement accepted requests, sooner or later I'll do it
Projects
None yet
Development

No branches or pull requests

2 participants