Check gcc version for diagnostic once.
Fix gcc version check for noexcept.