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 2191

Summary: SDL2-2.0.1/src/video/SDL_egl.c:397: possible bad if test ?
Product: SDL Reporter: David Binderman <dcb314>
Component: videoAssignee: Gabriel Jacobo <gabomdq>
Status: RESOLVED FIXED QA Contact: Sam Lantinga <slouken>
Severity: normal    
Priority: P2 CC: amaranth72, gabomdq
Version: 2.0.1   
Hardware: x86_64   
OS: Linux   

Description David Binderman 2013-10-28 16:59:55 UTC
I just compiled SDL2-2.0.1 with gcc compiler flag -Wlogical-op

It said

/home/dcb/rpmbuild/BUILD/SDL2-2.0.1/src/video/SDL_egl.c:397:5: warning: logical 'and' of mutually exclusive tests is always false [-Wlogical-op]

Source code is

    if (!egl_context && egl_context != EGL_NO_CONTEXT) {

Suggest code rework.
Comment 1 Gabriel Jacobo 2013-10-30 12:40:16 UTC
I may be still jet lagged, but I don't understand the warning...the test is "if egl_context is not null and it is not EGL_NO_CONTEXT then...", they are not mutually exclusive, why does GCC think it is?
Comment 2 Alex Szpakowski 2013-10-30 21:32:29 UTC
The test is "if egl_context *is* null and it is not EGL_NO_CONTEXT", which I suspect was not the intention when that was written. :)
Comment 3 Gabriel Jacobo 2013-10-31 13:04:31 UTC
You learn new things every day, today I learned to not make a fool of myself by not getting enough rest before doubting GCC :)

Thanks guys!

http://hg.libsdl.org/SDL/rev/0bca3fe7c03f