I am using an LM258D opamp connected as a comparator, beeing supplied by single voltage 5.1Vdc. Would you be able to tell me what it's gonna be happen if the input (+) voltage is higher than the opamp supply? For ecample what will happen if the input voltage (+) will be at 30Vdc ?

(4) The input common-mode voltage of either input signal voltage should not be allowed to go negative by more than 0.3 V (at 25°C). The upper end of the common-mode voltage range is V+ -1.5 V (at 25°C), but either or both inputs can go to 32 V without damage (26 V for LM2904), independent of the magnitude of V+.

So, for normal operation the input must not exceed (+ve pin - 1.5V) but no harm will happen if it goes to 32V.

But 30V is very close to 32V which is the absolute maximum.

'This forum helps those who help themselves.'

pragmatic►adjective dealing with things sensibly and realistically in a way that is based on practical rather than theoretical consideration.

From my interpretation of the datasheet, as long as one of the inputs is within valid range (-0.3 to VCC - 1.5V) then the output will at least have the correct phase, so it should work OK as comparator.