I live in UK, working for a unicorn startup company, and moved to here from a behemoth of a company operating over 50 countries both had the clause in my contract.
The loophole in contract law, is you can create confidential flags in bilateral contracts.
So saying āyou can be dismissed for sharing your salaryā is not valid because of the equalises act, but you can say āx, y and salary are confidential informationā and employment tribunal held this decision in quite a few examples.
Another point that I am going to make is not against you at all @Gez050 but general to all the āequalityā discussion above.
Not many jobs are easily quantifiable on merit (except may be physical labour intensive jobs) and in most jobs, most companies even struggle to asses how good/bad some individual or team is doing, especially for engineering and technical jobs. Keeping this in mind saying āBoth person A and B are doing the same jobā is only hypothetical and in real world it is actually naive.