GLSL control flow bug? (with short reproducable sample)

Hi all,

I would expect the following fragment shader to return red (1,0,0) at every pixel. On my phone, it does, but when using my pc with Nvidia GPU, the resulting image is black.

void mainImage( out vec4 fragColor, in vec2 fragCoord )
{
    float v = (fragCoord.x * 0.) + 1.0; // = 1.0
    int i = v > 0. ? 0 : 1; // = 0
    
    for(; i < 1; i++) // from 0 to 1 => execute once
    {
        for(int j = 0; j < 1; j++)  // from 0 to 1 => execute once
        {
            if(v > 0.) // always true
            {
                fragColor = vec4(1,0,0,1); // so why is this statement not executed?
                return;
            }
        }
    }
    
    fragColor = vec4(0,0,0,1);
    return;
}

Interactive demo at https://www.shadertoy.com/view/ssdXz8

Making seemingly irrelevant changes, such as replacing (fragCoord.x * 0.) with (1.0 * 0.), or commenting out the second for-statement, seem to remove the glitch.

I’m using the latest Nvidia drivers on Windows 10 with a GeForce RTX 3070Ti.

Am I somehow triggering undefined behavior?