https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81248
--- Comment #4 from wilhelm.me...@hs-kl.de --- Here a more stripped down example (without the volatile part): #include <cstdint> #include <type_traits> struct A { uint8_t m1{0}; }; volatile uint8_t v; template<typename T> void f(const T& x) __attribute__((noinline)); template<typename T> void f(const T& x) { if constexpr(std::is_same<T, A>::value) { v = x.m1; } else { v = x; } } uint8_t n1; A n2; int main() { f(n1); f(n2); }