Repository navigation
Names in default template arguments not found during partial specialization matching #482
jakub-labenski
started this conversation in
Issue Triage - Compilation
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Issue Summary
A class template's default template argument can be looked up in the wrong context. This happens when the default argument is filled in while the front end matches a partial specialization of a different template. Names in the default argument are then looked up from where that partial specialization is declared, instead of where the class template is declared. Anything declared after the partial specialization is not found, and the substitution is wrongly treated as failing.
In practice this breaks the common
void_tdetection idiom: the "is this well-formed" trait quietly returnsfalse. Nothing is diagnosed at the point of the mistake, so the result is a wrongstatic_assertresult or the wrong overload being chosen. The code compiles with GCC, Clang and MSVC.Reproducing Source Code
Command-line Options
cpfe --c++17 repro.cpp
Type of Issue
[Front End] This code SHOULD compile with these options.
Additional Details
Actual output:
Observations:
--c++14,--g++and--clang.--microsoft). That mode turns off dependent name processing, so names in templates are looked up later, when the template is used. It does reproduce with--microsoft --dep_name.namespace libabove the partial specialization ofokmakes the code compile, so the bug depends on declaration order.A<V>itself can be used directly with no problem. The failure only happens whenA's default argument is filled in while theok<void_t<TT<P...>>, TT, P...>partial specialization is being matched.struct is_detected<void_t<...>, ...>) behave the same way.Reproducing (Standard) Configuration(s)
linux-gcc-debug
Reproducing (Non-standard) Configuration
No response
I acknowledge that:
LICENSE.txtfile in my.zipor.tar.gzupload. If I included aLICENSE.txtfile, any tests created using the reproducing source code will be governed by the terms of the license I provided instead.All reactions