We are currently migrating Bugzilla to GitHub issues.
Any changes made to the bug tracker now will be lost, so please do not post new bugs or make changes to them.
When we're done, all bug URLs will redirect to their equivalent location on the new bug tracker.

Bug 4095

Summary: fix strict aliasing warnings in SDL_test_fuzzer.c
Product: SDL Reporter: Ozkan Sezer <sezeroz>
Component: *don't know*Assignee: Ryan C. Gordon <icculus>
Status: RESOLVED FIXED QA Contact: Sam Lantinga <slouken>
Severity: normal    
Priority: P2    
Version: HG 2.0   
Hardware: x86   
OS: Linux   
Attachments: SDL_test_fuzzer.c strict aliasing patch

Description Ozkan Sezer 2018-02-25 07:20:05 UTC
Created attachment 3181 [details]
SDL_test_fuzzer.c strict aliasing patch

I always get the following warnings from SDL_test_fuzzer.c:

src/test/SDL_test_fuzzer.c: In function 'SDLTest_RandomUint64':
src/test/SDL_test_fuzzer.c:130: warning: likely type-punning may break strict-aliasing rules: object '*vp' of main type 'unsigned int' is referenced at or around src/test/SDL_test_fuzzer.c:134 and may be aliased to object 'value' of main type 'long long unsigned int' which is referenced at or around src/test/SDL_test_fuzzer.c:129.
src/test/SDL_test_fuzzer.c:135: warning: likely type-punning may break strict-aliasing rules: object '*{unknown}' of main type 'unsigned int' is referenced at or around src/test/SDL_test_fuzzer.c:135 and may be aliased to object 'value' of main type 'long long unsigned int' which is referenced at or around src/test/SDL_test_fuzzer.c:129.

The attached patch fixes it by using a union instead of type-punning.
Comment 1 Sam Lantinga 2018-02-25 17:46:00 UTC
Added, thanks!
https://hg.libsdl.org/SDL/rev/732b6ef4aae7