A tricky issue with comparators, which data sheets aren't always clear about, is that the term "common mode range" may describe any three different concepts:
A range beyond which inputs may be "pegged", causing excessive current to flow in the device and perhaps causing damage.
A range beyond which inputs may behave as though they are "pegged", without causing device damage. If both inputs are above the the range or both are below the range, either input may behave as though pegged at a level above or below the other, meaning the output might be arbitrarily high or low. If only one input is above the top of the range, however, it would be above the other input even if pegged to the top of the range, and likewise if below the bottom.
A range which, if exceeded, would not cause damage to the device but might cause unpredictable behavior if exceeded by either input. Raising an input above the top of the range may cause the device to behave as though it is below the bottom of the range, or vice versa. This behavior can cause some comparator-based circuit designs to "get stuck", if they try to use a comparator's output to bring a voltage back in range. Once an input gets far enough above the top of the range to make the output report it as being lower than the other input, a feedback loop which causes that input to go higher whenever it's lower than the other would push that input further out of range.
Unfortunately, data sheets aren't always clear on which kind of limitation applies near the positive rail and near the negative rail. As Russell McMahon notes, the LM393 data sheet is nice in that regard, but many data sheets aren't.
Incidentally, if anyone is curious why behavior #3 would occur, the following is a simplified but conceptually typical comparator design. You may click "simulate" link below, then the "Simulate" button and "Run time domain simulation" to see how it works.
simulate this circuit – Schematic created using CircuitLab
Notice that most of the time, the output will be low when the slowly-changing signal is below the quickly-changing one, but when the slowly changing signal approaches ground the output will go high. This happens because the output goes low in response to current flowing from the collector of Q2 into the base of Q3. This requires not only Q2 be turned on, but also that its emitter voltage be higher than the collector (which is tied to Q3's base). If the base input is too low, Q2 will be switched on, but the current flowing from the emitter to the base will pull the emitter too low for it to convey any current to Q3's base.
Comparator ICs use more than three transistors, of course, but many have an input stage which is somewhat similar to this. Comparators that are designed for "rail to rail" operation often combine a circuit similar to this one with a circuit that's essentially a "mirror image" version where the input transistors would ground an output signal in response to a higher voltage (which would work well near the bottom rail, but fail near the top rail), and then switch between the outputs of the two circuits as needed to yield correct operation.