SDL_test_fuzzer.c: fix strict aliasing warnings by using a union.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
diff --git a/src/test/SDL_test_fuzzer.c b/src/test/SDL_test_fuzzer.c
index 37b9dc3..eee56a9 100644
--- a/src/test/SDL_test_fuzzer.c
+++ b/src/test/SDL_test_fuzzer.c
@@ -126,29 +126,35 @@ SDLTest_RandomUint32()
Uint64
SDLTest_RandomUint64()
{
- Uint64 value = 0;
- Uint32 *vp = (void *)&value;
+ union {
+ Uint64 v64;
+ Uint32 v32[2];
+ } value;
+ value.v64 = 0;
fuzzerInvocationCounter++;
- vp[0] = SDLTest_RandomSint32();
- vp[1] = SDLTest_RandomSint32();
+ value.v32[0] = SDLTest_RandomSint32();
+ value.v32[1] = SDLTest_RandomSint32();
- return value;
+ return value.v64;
}
Sint64
SDLTest_RandomSint64()
{
- Uint64 value = 0;
- Uint32 *vp = (void *)&value;
+ union {
+ Uint64 v64;
+ Uint32 v32[2];
+ } value;
+ value.v64 = 0;
fuzzerInvocationCounter++;
- vp[0] = SDLTest_RandomSint32();
- vp[1] = SDLTest_RandomSint32();
+ value.v32[0] = SDLTest_RandomSint32();
+ value.v32[1] = SDLTest_RandomSint32();
- return value;
+ return (Sint64)value.v64;
}