HaddingtonDynamics / Dexter

GNU General Public License v3.0
374 stars 85 forks source link

DexRun.c casts a float into an unsigned int #48

Open JamesNewton opened 5 years ago

JamesNewton commented 5 years ago

DexRun.c casts a float into an unsigned int. This generates the warning:

DexRun.c: In function 'SetParam':
DexRun.c:3868:2: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
  unsigned int *uia2 = *(unsigned int*)&fa2;
  ^
DexRun.c:3868:23: warning: initialization makes pointer from integer without a cast [-Wint-conversion]
  unsigned int *uia2 = *(unsigned int*)&fa2;
                       ^

To correct this, memcpy can be used:
https://stackoverflow.com/questions/17789928/whats-a-proper-way-of-type-punning-a-float-to-an-int-and-vice-versa

JamesNewton commented 3 years ago

Kamino cloned this issue to HaddingtonDynamics/OCADO