Bug report: unexpected behaviour of glUniformSubroutinesuiv when some subroutine uniforms are inactive

I found an unexpected behaviour in the implementation of glUniformSubroutinesuiv(GLenum shadertype, GLsizei count, const GLuint *indices). The problem comes when there are inactive subroutine uniform arrays in the shader. When it happens, passing the actual number of uniform indices as “count” value (i.e., equal to ACTIVE_SUBROUTINE_UNIFORM_LOCATIONS, as written in the OpenGL specifications), will generate the INVALID_VALUE error (that is the opposite to what specified). Instead, it works passing the total number of uniform indices (that is, including the inactive ones). Clearly, the problem is both that it does not respect OpenGL specifications and that there is no way to get inactive subroutine info via OpenGL introspection (all the commands are related to the active ones).

Examples:

fragment shader

subroutine uniform SubroutineTypeName1 SubroutineUniformNameA[6];
subroutine uniform SubroutineTypeName2 SubroutineUniformNameB[2];

app

int subroutineLocations;
glGetProgramStageiv(program, GL_FRAGMENT_SHADER, GL_ACTIVE_SUBROUTINE_UNIFORM_LOCATIONS, &subroutineLocations);
// subroutineLocations == 8
glUniformSubroutinesuiv(GL_FRAGMENT_SHADER, subroutineLocations, &indices[0]); // it works as expected
auto err = glGetError() // returns 0

fragment shader

subroutine uniform SubroutineTypeName1 SubroutineUniformNameA[6];
subroutine uniform SubroutineTypeName2 SubroutineUniformNameB[2]; // inactive subroutine uniform (not used anywhere)

app

int subroutineLocations;
glGetProgramStageiv(program, GL_FRAGMENT_SHADER, GL_ACTIVE_SUBROUTINE_UNIFORM_LOCATIONS, &subroutineLocations);
// subroutineLocations == 6
glUniformSubroutinesuiv(GL_FRAGMENT_SHADER, subroutineLocations, &indices[0]); // it doesn't work
auto err = glGetError() // returns 1281 (INVALID_VALUE) NB: the values of indices are lesser than GL_ACTIVE_SUBROUTINES as requested

fragment shader

subroutine uniform SubroutineTypeName1 SubroutineUniformNameA[6];
subroutine uniform SubroutineTypeName2 SubroutineUniformNameB[2]; // inactive subroutine uniform (not used anywhere)

app

int subroutineLocations;
glGetProgramStageiv(program, GL_FRAGMENT_SHADER, GL_ACTIVE_SUBROUTINE_UNIFORM_LOCATIONS, &subroutineLocations);
// subroutineLocations == 6
glUniformSubroutinesuiv(GL_FRAGMENT_SHADER, <b>8</b>, &indices[0]); // it works, contrarily to what expected
auto err = glGetError() // returns 0

System information:

OS: Microsoft Windows 7 64bit
Device: Quadro K620
Driver Version: 368.86
OpenGL context: 4.3