https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109018
--- Comment #6 from qingzhe huang <nickhuang99 at hotmail dot com> --- I agree "Note g can be still found after the declaration via argument dependent lookup." Can we view this issue from a different angle? The real work of parsing should be started at "template function definition". So, if the "template function declaration" is invalid because of "scope" of "g", then the "valid" definition DOES NOT belong to the "invalid" declaration. i.e. There are tons of invalid declaration are discarded as they are not required for template function instantiation.