Are uniforms of the same name the same uniform between different shader programs?

In the wiki on uniforms, it is said:

OpenGL does not guarantee that the same uniforms in the two programs will have the same location.

This would imply that sometimes they may in fact be the same?

I ask because I have two shaders but they have same-name uniforms. I had previously assumed that when I switch between shaders, the uniform data will be the same as the uniform data during that shader’s last use.

But this appears to not be correct. Instead, I have to reset a uniform when I switch to the shader, even if I had used the same shader seconds before without difficulty.

Is it normal to reset all the uniforms when you change to a new shader?

This would imply that sometimes they may in fact be the same?

Even if they are, and yes, they may actually be the same, you cannot and should not rely on something that the GL does not guarantee! In case you assign explicit uniform locations (core in 4.3) this of course looks a bit different, since it’s not the GL anymore which assigns the locations, but the programmer.

The wiki also clearly states, that uniforms usually do not change between program executions - this, however, refers to executions of the same program, not two different programs. If you set the uniform values for program 1, it will not affect the uniform values of program 2, even if they are equally named and are assigned the same location by the GL. The uniforms for both programs belong to distinct state vectors!

The GL spec states the following to be part of the required state for program objects:

Also, switching a shader program will simply reinstate the last set value for each active uniform. You should not have to set the value anew. So no, it’s not normal to change the uniform values when switching programs, at least not for the sole purpose of resetting the same uniform values as before.