-
Notifications
You must be signed in to change notification settings - Fork 53
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
Warning "conversion from ‘int’ to ‘float’ may change value" when using integer values #31
Comments
Can you tell me which compiler you're using and compiler flags? |
GCC (Raspbian 8.3.0-6+rpi1) 8.3.0 I have temporarely solved the problem like this: #pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wconversion"
#include "tweeny/tweeny.h"
#pragma GCC diagnostic pop But this is, of course, not a proper fix. |
Not saying they aren't! I take warnings seriously, it's just that the last time I compiled something with tweeny myself I had no warnings, mostly because -Wconversion isn't enabled with -Wall? or wasn't, at least. I wanted to check which variables are giving out these warnings as, giving the template-heavy nature of tweeny, simply casting it with static cast might break things with user-defined classes and user-defined casting. I'll reproduce it and fix as soon as possible, thanks for your workaround for GCC, though. |
Right, so, it is as I thought. I cannot simply Consider: struct boxed_float {
float value;
boxed_float() : value(0) { }
boxed_float(float v) : value(v) { }
};
boxed_float operator+(const boxed_float & a, const boxed_float & b) { return {a.value + b.value}; }
boxed_float operator-(const boxed_float & a, const boxed_float & b) { return {a.value - b.value}; }
boxed_float operator-(const boxed_float & a) { return {-a.value}; }
boxed_float operator*(const boxed_float & a, const boxed_float & b) { return {a.value * b.value}; }
boxed_float operator/(const boxed_float & a, const boxed_float & b) { return {a.value / b.value}; }
...
auto t = tweeny::from(boxed_float{1.0f}).to(boxed_float{100.0f}).during(300).via(tweeny::easing::circularIn); Supporting composite types is a feature I value in tweeny so we need another solution here.
I'm truly tempted to go with the last one, at least for now. Any more input/opinions on this? |
When using integer values such as in this example:
The compiler issues warnings for the conversion from int to float for all the different easings, sometimes multiple warnings per easing. I don't want to disable the warnings, because they may be valuable information pointing out where a possible bug exists.
It would be nice if a
static_cast<float>()
is used where appropriate, so that my warnings list is not flooded.The text was updated successfully, but these errors were encountered: