The article "Employers, employees and consultants - who owns what when it comes to intellectual property?" by Laura Harper says that in the UK:
The general rule in relation to IP created by an employee during the course of their employment is that, in the absence of agreement to the contrary, the first owner is the employer. The article says that thsi follows from provision in the Patents Act 1977, the Copyright Designs and Patents Act 1988, the Registered Designs Act 1949, and the Regulation on Community Designs (6/2002/EC).
A key provision here is "during the course of their employment". The article goes on to explain that:
Most IP disputes which arise between an employer and an employee hinge on whether the intellectual property in question has been created 'during the course of employment'. This is determined by a number of factors including whether the work falls within the job description of the employee, whether the work was created during working hours, whether the employee could have reasonably been expected to create the work and whether any agreement exists relating to the work between the employer and the employee. However, it is useful to note that just because a work is created during working hours does not necessarily mean that the intellectual property in that work is owned by the employer (though this may give rise to a disciplinary procedures for misuse of company time, computer equipment etc). Similarly, if work is produced outside working hours but falls squarely within the job description of the employee then it may be that the first owner of that intellectual property in the product of that work is the employer, notwithstanding the fact that the work was created, for example, in the evening.
The article also says that:
As a consultant is an independent party then unless otherwise agreed, all IP created by a consultant will be owned by them and not the company engaging the consultant.
Therefore, it is important that companies ensure that an appropriate consultancy agreement is entered into between the company and the consultant.
It seem clear that absent an agreement to the contrary, a UK employer will own work that is created as part of an employee's job, even if outside of working hours. However, it is not at all clear to me if a "sweeping" agreement which claims all IP, even if outside of hours and in no way related to the contracted job, will be considered valid and enforceable.
In such a case it may be best to obtain a specific agreement with the "daytime" employer (company D, let's say) that D makes no claim on work done by consultant C for second employer S. That has the possible downside of alerting D to the situation, and si something about which S should probably consult S's own lawyer.