cglm icon indicating copy to clipboard operation
cglm copied to clipboard

Clang warnings for implicit conversions from float to double

Open CaspianA1 opened this issue 4 years ago • 1 comments

When using the clang flag -Wdouble-promotion and including <cglm/cglm.h>, a maelstrom of implicit float-to-double conversion errors arise. Here is a small snippet of the 23 warnings I got:

/usr/local/include/cglm/vec2-ext.h:65:13: warning: implicit conversion increases floating-point precision: 'float' to 'double' [-Wdouble-promotion]
         && fabsf(v[1] - val) <= GLM_FLT_EPSILON;
            ^~~~~~~~~~~~~~~~~ ~~
/usr/local/include/cglm/vec2-ext.h:64:10: warning: implicit conversion increases floating-point precision: 'float' to 'double' [-Wdouble-promotion]
  return fabsf(v[0] - val) <= GLM_FLT_EPSILON
         ^~~~~~~~~~~~~~~~~ ~~
/usr/local/include/cglm/vec2-ext.h:101:13: warning: implicit conversion increases floating-point precision: 'float' to 'double' [-Wdouble-promotion]
         && fabsf(a[1] - b[1]) <= GLM_FLT_EPSILON;
            ^~~~~~~~~~~~~~~~~~ ~~
/usr/local/include/cglm/vec2-ext.h:100:10: warning: implicit conversion increases floating-point precision: 'float' to 'double' [-Wdouble-promotion]
  return fabsf(a[0] - b[0]) <= GLM_FLT_EPSILON
         ^~~~~~~~~~~~~~~~~~ ~~

I do not have the time, but if someone does, please declare the preprocessor constant GLM_FLT_EPSILON as a float. This not being the case is the sole cause of the warnings.

CaspianA1 avatar Nov 08 '21 00:11 CaspianA1

Hi @CaspianA1

Thanks for reporting this, I'll take a look at asap to fix it

recp avatar Nov 08 '21 18:11 recp

@CaspianA1 this is feed at https://github.com/recp/cglm/pull/273 many thanks

recp avatar Dec 31 '22 18:12 recp