mirror of
https://github.com/Unidata/netcdf-c.git
synced 2025-02-23 16:59:54 +08:00
Fix type punning in val_NC_check_voff() by using memcpy instead of assignment
gcc11 explicitly warns about this strict aliasing violation: daux.c:903:30: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing] 903 | params[nparams++] = *(unsigned int*)&valf; | | ^~~~~~~~~~~~~~~~~~~~ Signed-off-by: Egbert Eich <eich@suse.com>
This commit is contained in:
parent
269ff33844
commit
fbad04ee79
@ -900,7 +900,8 @@ filterspec_cvt(const char* txt, size_t* nparamsp, unsigned int* params)
|
||||
sstat = sscanf(p,"%lf",&vald);
|
||||
if(sstat != 1) {stat = NC_EINVAL; goto done;}
|
||||
valf = (float)vald;
|
||||
params[nparams++] = *(unsigned int*)&valf;
|
||||
/* avoid type punning */
|
||||
memcpy(¶ms[nparams++], &valf, sizeof(unsigned int));
|
||||
break;
|
||||
/* The following are 8-byte values, so we must swap pieces if this
|
||||
is a little endian machine */
|
||||
|
Loading…
Reference in New Issue
Block a user