The American Chemical Society has released a fact-packed video about peeing in pools, explaining what the health consequences of relieving yourself in them are.
Chlorine, along with other methods, is used to sterilize the still water in pools from various microorganisms. Chlorine is very reactive, which makes it great to get rid of unwanted bacteria, but it also means that it reacts with whatever organic matter humans bring into public pools.
Sweat, dirt, urine, and sun lotion all react with the chlorine, creating compounds generally called disinfection byproducts. Among these, there's trichloramine, a nitrogen-chlorine molecule that forms when chlorine reacts with urine. Trichloramine, an irritant, is responsible for both the nice pool smell and why your eyes go red in swimming pools.
As the video suggests, shower and use the toilet before you go for a swim. For everyone’s sake.