Two issues here: one, we were failing to look through references when comparing types, so we decided that a function type in a template non-type argument didn't match a reference-to-function type in the type of the non-type parameter. With that fixed, I also needed to move the C++17 non-type auto handling down past that type comparison. Tested x86_64-pc-linux-gnu, applying to trunk and 7.