I'm sorry but as I do with all these misconceptions I have to chime in here. Rooting, S-offing and installing custom roms cannot void a warranty as the warranty on an electrical item covers the hardware for faults, when not caused by human error.
If I install a custom ROM on a phone, and then the screen stops working, which has happened to me countless times in the past, I will simply send it to HTC and they repair it.
HTC, Carphonewarehouse, Orange, and Phones4u in the UK have never refused me a repair on a phone or indeed a replacement due to s-off or a custom ROM,
I traded in my old M7 with Venom rom on, S-off in phones4u, to get my M8 and they didn't even flinch at that either.
I am not saying anything beyond, most people asking this will s-off anyway, and if you really are scared of losing your warranty, you'll also find a way of getting it back to s-on and locked too.