Merge pull request #3413 from Optimizer0/master

[Bug-Fix] Fixed Strict Aliasing Level 3 Warnings
pull/3446/head
Kim Kulling 2020-10-08 10:17:32 +02:00 committed by GitHub
commit c7ab7ff457
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 3 deletions

View File

@ -197,12 +197,15 @@ M3D_INDEX addMaterial(const Assimp::M3DWrapper &m3d, const aiMaterial *mat) {
break; break;
case m3dpf_float: case m3dpf_float:
if (mat->Get(aiProps[k].pKey, aiProps[k].type, if (mat->Get(aiProps[k].pKey, aiProps[k].type,
aiProps[k].index, f) == AI_SUCCESS) aiProps[k].index, f) == AI_SUCCESS) {
uint32_t f_uint32;
memcpy(&f_uint32, &f, sizeof(uint32_t));
addProp(&m3d->material[mi], addProp(&m3d->material[mi],
m3d_propertytypes[k].id, m3d_propertytypes[k].id,
/* not (uint32_t)f, because we don't want to convert /* not (uint32_t)f, because we don't want to convert
* it, we want to see it as 32 bits of memory */ * it, we want to see it as 32 bits of memory */
*((uint32_t *)&f)); f_uint32);
}
break; break;
case m3dpf_uint8: case m3dpf_uint8:
if (mat->Get(aiProps[k].pKey, aiProps[k].type, if (mat->Get(aiProps[k].pKey, aiProps[k].type,

View File

@ -3590,7 +3590,7 @@ m3d_t *m3d_load(unsigned char *data, m3dread_t readfilecb, m3dfree_t freecb, m3d
case 4: f = (float)(*((float *)(data + 0))); break; case 4: f = (float)(*((float *)(data + 0))); break;
case 8: f = (float)(*((double *)(data + 0))); break; case 8: f = (float)(*((double *)(data + 0))); break;
} }
h->cmd[i].arg[k] = *((uint32_t *)&f); memcpy(&(h->cmd[i].arg[k]), &f, sizeof(uint32_t));
data += model->vc_s; data += model->vc_s;
break; break;
case m3dcp_hi_t: data = _m3d_getidx(data, model->hi_s, &h->cmd[i].arg[k]); break; case m3dcp_hi_t: data = _m3d_getidx(data, model->hi_s, &h->cmd[i].arg[k]); break;