If an application or upper-layer specifies a source address that is not in the candidate set for the destination, then the network layer MUST treat this is an error. If the application or upper-layer specifies a source address that is in the candidate set for the destination, then the network layer MUST respect that choice. This source address selection algorithm only applies to IPv6 destination addresses, not IPv4 addresses. The pair-wise comparison consists of eight rules, which should be applied in order. If a rule chooses an address, then the remaining rules are not relevant and should be ignored.
Subsequent rules act as tie-breakers for earlier rules.
If the eight rules fail to choose an address, some unspecified tie-breaker should be used. Prefer same address. Prefer appropriate scope. Use longest matching prefix. Rule 8 may be superceded if the implementation has other means of choosing among source addresses.