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 4999

Summary: MSVC Static analysis: Incorrect alpha_value check in SDL_render.c
Product: SDL Reporter: Cameron Gutman <cameron.gutman>
Component: renderAssignee: Sam Lantinga <slouken>
Status: RESOLVED FIXED QA Contact: Sam Lantinga <slouken>
Severity: normal    
Priority: P2 CC: sylvain.becker
Version: HG 2.1   
Hardware: x86   
OS: Windows 10   

Description Cameron Gutman 2020-02-21 19:53:57 UTC
MSVC's static analysis found this one and it looks like a legitimate bug.

"Incorrect operator: mutual exclusion over || is always a non-zero constant.  Did you intend to use && instead?"

    /* If Palette contains alpha values, promotes to alpha format */
    if (fmt->palette) {
        for (i = 0; i < fmt->palette->ncolors; i++) {
            Uint8 alpha_value = fmt->palette->colors[i].a;
            if (alpha_value != 0 || alpha_value != SDL_ALPHA_OPAQUE) { <---- HERE
                needAlpha = SDL_TRUE;
                break;
            }
        }
    }


https://hg.libsdl.org/SDL/file/28fcb5ef7ff1/src/render/SDL_render.c#l1170
Comment 1 Sylvain 2020-02-23 08:58:44 UTC
Thanks good catch ! palette surface were then always promoted to alpha.
https://hg.libsdl.org/SDL/rev/c66d1c7700bd

(At the same time, I spotted another issue and re-open bug 4425)