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 3593

Summary: Unknown behaviour in src/events/SDL_mouse.c:66:26: runtime error: shift exponent -1 is negative
Product: SDL Reporter: Andrei Karas <akaras>
Component: eventsAssignee: Ryan C. Gordon <icculus>
Status: RESOLVED FIXED QA Contact: Sam Lantinga <slouken>
Severity: minor    
Priority: P2 CC: akaras, icculus
Version: HG 1.2   
Hardware: All   
OS: All   

Description Andrei Karas 2017-02-27 17:56:11 UTC
Hello,
SDL compiled with gcc 6 and asan/ubsan found this issue:

src/events/SDL_mouse.c:66:26: runtime error: shift exponent -1 is negative

This from macro SDL_BUTTON in function SDL_ResetMouse.
I think from SDL_BUTTON(0)  ->  1 << -1

Negative offset is unknown behaviour. And may works or not in current and in future compilers.

This issue present in HG 1.2 and HG 2.0 and probably in other older versions.
Comment 1 Ryan C. Gordon 2017-06-01 04:40:09 UTC
SDL_ResetMouse has been disabled since before 2.0.0 shipped:

  https://hg.libsdl.org/SDL/rev/36ce2e6166e7

But that code is definitely wrong in 1.2. Even before removing SDL_ResetMouse, somewhere in 1.3 someone fixed this, so I've made the same fix in 1.2 now:

  https://hg.libsdl.org/SDL/rev/1138bf8c009a

--ryan.