Pitch is a compromise, by design, on any modern instrument. Not just on guitar.
It's not possible to have perfect intonation in any standard tuning, and that is because in order to play in more than one key, tempered tuning is necessary. This is true of any instrument tuned to what we today refer to as standard tuning, not just guitar. While any compensated guitar sounds better than most, the fact is that it's imperfect because the scale itself is a compromise due to the physics of sound.
Centuries ago, someone figured out Just Intonation, which was based mathematically on the harmonic overtones of one scale. It was perfect, but unfortunately, it only worked in one key. The instrument had to be re-tuned to change keys (you can imagine how difficult this is on some instruments, like pianos, or instruments like flutes whose holes are drilled at certain intervals). If the key went from, say, C to D, everything was horribly off.
Tempered tunings were invented (and there are several types) that made it possible to play in every key, though these involve imperfections in intonation. This is why different keys have slightly different "colors," but also made modern musical techniques a lot easier to listen to. Hence Bach's "Well Tempered Clavier" compositions - he was referring to the keyboard's ability to play in many keys, not its ability to avoid mood swings.
In fact, the issue of Temperament was a big deal in Bach's day.
So any tuning other than "Just" Intonation involves compromise, whether you're playing guitar, piano, or clarinet. There is no such thing as a perfect scale. It doesn't exist unless you go to Just Intonation.
This is why guitars aren't perfect up and down the fretboard. Most other instruments aren't perfect either. They aren't designed to be.
Our ears are trained to accept imperfections in pitch due to tempered tunings, and it's the kind of thing that drives some musicians batty! If you listen to orchestras that play early music on historical instruments, everything sounds oddly off; it takes a few minutes to get used to the sound. That's partly because of the temperament practices of the day, not just because we're not used to the sound of crumhorns and rebecs.
It's my belief that the many uses of vibrato and ornamentation we use in modern music were developed to help disguise the imperfection involved in simply holding a note resulting from tempered tunings.
In fact, tuning an instrument like a piano, with several strings devoted to a single key, plus harmonic strings, is an acknowledged art; serious studios and concert players pay hundreds of dollars (often more for important concerts and session dates) to have their instruments tuned by the best piano tuners, who are themselves often concert musicians - it can't be done properly with a strobe tuner like on guitar - and it can take a full day or more to do. And a Bach player wants the piano tuned slightly differently from a Brahms player.