Maybe that's the case now, with GCC 8, but historically that hasn't been true.
In the past the effects of using both -g and -O* flags could interact each other because they can both affect how registers are allocated, how call stacks are setup, how functions are inlined, etc. In other words, adding -g by itself made the build non-reproducible.
If that's no longer true in GCC 8 it's great news.