You may be relived to know that Unix epoch time does not have this problem. But you may also be horrified to know why.
First, epoch seconds are not the numbers of seconds since 1970/01/01. This is a lie we tell to children. Rather, epoch seconds are the number of days since 1970/01/01 * 86400 plus the number of seconds since midnight.
Leap seconds, to epoch time, don't exist. Or maybe they are double counted. Or maybe we smear them over 12 or 24 hours (but which 12 or 24 hours depends on whether you are Google, Microsoft, or Oracle; I can't even make this stuff up). The point is, it's not defined, and this means implementations do it differently.
A negative leap second might be easier though. The spec suggests (though lack of speaking) that a correct implementation will just skip it since number of seconds stays less than 86400 for that day. But of course the smear-organizations still smear it.
So what if you really want to know how many seconds were between two different epochs? Subtracting epoch seconds is wrong because you need to correct for the number of leap seconds between the two times.
And the smears.
Yes, it's wrong. But we have also agreed to all be wrong in the same way. Except during the specific day that we are wrong in different ways.
Correction: We are mostly right, most of the time, but wrong in ways most people don't notice except if they try to talk while everyone is wrong.
Clarification: Human perception of time is not understandable, and the machine abstraction even less so.
Indeed. I like to say, we would like three things to be true:
1) Every day has 86400 seconds.
2) Every day is from noon (sun exactly above) to noon (sun exactly above).
3) We use SI seconds.
You can't have all three. Pick any two:
1, 2, not 3: What you describe. Day has 86400 seconds, we keep in sync with the sun, but we tweak the seconds a bit. There are different versions, like epoch time, or UT1.
1, not 2, 3: Every day has 86400 SI seconds, and we slowly go out of sync with the sun. That's TAI.
not 1, 2, 3: We use SI seconds and keep in sync with the sun +/- 1 second, but need to add/drop seconds occasionally. That's UTC.
https://en.wikipedia.org/wiki/Universal_Time
https://en.wikipedia.org/wiki/International_Atomic_Time
https://en.wikipedia.org/wiki/Coordinated_Universal_Time