Thanks everyone. Good to know he's not alone at least! And I'm getting some advice on the other thread too.
Littlefish, I don't tend to talk to his teachers about it, because I know it makes him worse if he thinks people are noticing, or pressuring him to go to the toilet when he doesn't feel he needs to, especially if he is singled out in front of other children. An after-school tennis coach went through a phase of drawing attention to the problem, and raising it with me regularly at pick-up time, and the situation rapidly worsened until I asked the coach to just ignore it. Then it resolved itself.
His class teacher is male, and much admired by DS. I think DS would be mortified if he knew I'd spoken to him about it, but I suspect the teacher may have noticed anyway.
He has been caught out a couple of times when he's asked to go to the loo during class, and has been told he has to wait until break (not by his class teacher, but by stand-ins who don't know him so well). A more assertive child would be insistent if they were desperate, and would be allowed out, but its rare for DS to ask once, never mind twice.
I do advise him to make strategic toilet trips, and it helps when he does that, but he's not self-organised enough to do it consistently at school, especially if he's having fun with his friends. I think he needs to recognise the problem first, and want to change. I just hope he gets to that point before teasing forces him there.