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 - Unknown behaviour in src/events/SDL_mouse.c:66:26: runtime error: shift exponent -1 is negative
Summary: Unknown behaviour in src/events/SDL_mouse.c:66:26: runtime error: shift expon...
Status: RESOLVED FIXED
Alias: None
Product: SDL
Classification: Unclassified
Component: events (show other bugs)
Version: HG 1.2
Hardware: All All
: P2 minor
Assignee: Ryan C. Gordon
QA Contact: Sam Lantinga
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-02-27 17:56 UTC by Andrei Karas
Modified: 2017-06-01 04:40 UTC (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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.