Repository navigation
Backlog
Backlog
Copy link
Description
Issue Summary
When a dependent template-id names a non-template member after substitution, the front end emits an error instead of treating the invalid expression as a substitution failure. This breaks detection idioms for non-template member functions and both non-static and static data members: the partial specialization is incorrectly selected instead of falling back to the primary template.
Reproducing Source Code
template<typename...> using void_t = void;
template<typename T, typename = void> constexpr bool has_f = false;
template<typename T>
constexpr bool has_f<T, void_t<decltype(&T::template f<>)>> = true;
struct Plain { int f() const; };
struct Data { int f; };
struct StaticData { static int f; };
struct Generic { template<typename = void> int f() const; };
struct StaticGeneric { template<typename = void> static int f; };
static_assert(!has_f<Plain>);
static_assert(!has_f<Data>);
static_assert(!has_f<StaticData>);
static_assert(has_f<Generic>);
static_assert(has_f<StaticGeneric>);Command-line Options
--c++14
Type of Issue
[Front End] This code SHOULD compile with these options.
Additional Details
For Plain, Data, and StaticData, the front end warns that the name following template must be a template and then reports expected an expression. It subsequently fails the corresponding static assertions because has_f evaluates to true.
Reproducing (Standard) Configuration(s)
linux-gcc-debug
Reproducing (Non-standard) Configuration
No response
I acknowledge that:
- I have checked open issues and existing discussions before filing this report.
- The reproducing source code that I have provided does not depend on headers that I have not included with my submission.
- I have reduced the reproducing source code to the best of my ability.
- I have selected at least one standard configuration or uploaded a non-standard configuration dump.
- I understand code shared via this form is NOT confidential.
- I have permission to share the reproducing source code and grant permission for the project to use the source code (or derivatives of the source code) to create tests.
- I agree that any tests created using the reproducing source code (or deriatives of it) will be licensed under project license unless I included a
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.
Metadata
Metadata
Assignees
Labels
No labels
Activity
[GH edgcpp#598] Reject non-template members named by a template-id
Reject non-template members named by a template-id [GH edgcpp#598]