https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87614
--- Comment #5 from Jonathan Wakely <redi at gcc dot gnu.org> --- We have a concept of "inlining locations" in the compiler, and we only consider a warning location to be in a system header if all call sites along the inlining stack are in system headers. It seems that concept should be expanded to consider the template instantiation stack. It's not just whether any user code call site has been inlined into a system header location, but also whether user code call sites instantiate template code from system headers. It's probably not that simple though; not all warnings in templates instantiated by user code are due to the user code.