A program object that is successfully linked BUT has it's shaders detached can not be queried about it's binary - glGetProgramiv(prog, GL_PROGRAM_BINARY_LENGTH, &v) gives 0. Otherwise the program object works for rendering.
If the shaders are kept attached, then all works - the program obj is usable for rendering and the binary is retrievable.
This is a bug because, except for the linking, the attached shaders (or their lack thereof) should have no other effects on the program object. In particular they should not affect the binary.
I attached some simplified win32-based code that shows the bug.