mirror of
https://github.com/ETLCPP/etl.git
synced 2026-07-01 14:59:08 +08:00
Possible fix for 'strict aliasing' warnings.
This commit is contained in:
parent
ad0e3c4f8d
commit
98b0c888ea
17
src/hash.h
17
src/hash.h
@ -32,6 +32,7 @@ SOFTWARE.
|
||||
#define __ETL_HASH__
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
// The default hash calculation.
|
||||
#include "fnv_1.h"
|
||||
@ -322,7 +323,9 @@ namespace etl
|
||||
{
|
||||
if (sizeof(size_t) == sizeof(v))
|
||||
{
|
||||
return *reinterpret_cast<size_t*>(&v);
|
||||
size_t t;
|
||||
memcpy(&t, &v, sizeof(size_t));
|
||||
return t;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -344,7 +347,9 @@ namespace etl
|
||||
{
|
||||
if (sizeof(size_t) == sizeof(v))
|
||||
{
|
||||
return *reinterpret_cast<size_t*>(&v);
|
||||
size_t t;
|
||||
memcpy(&t, &v, sizeof(size_t));
|
||||
return t;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -366,7 +371,9 @@ namespace etl
|
||||
{
|
||||
if (sizeof(size_t) == sizeof(v))
|
||||
{
|
||||
return *reinterpret_cast<size_t*>(&v);
|
||||
size_t t;
|
||||
memcpy(&t, &v, sizeof(size_t));
|
||||
return t;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -387,7 +394,9 @@ namespace etl
|
||||
{
|
||||
if (sizeof(size_t) == sizeof(T*))
|
||||
{
|
||||
return reinterpret_cast<size_t>(v);
|
||||
size_t t;
|
||||
memcpy(&t, &v, sizeof(size_t));
|
||||
return t;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user