Skip to content

Dependent template-ids naming non-template members do not cause substitution failure #598

Backlog

Description

@nv-cmeerw

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.txt file in my .zip or .tar.gz upload. If I included a LICENSE.txt file, any tests created using the reproducing source code will be governed by the terms of the license I provided instead.

Activity

  1. added theissue type on Nov 27, 2026
  2. added 2 commits that reference this issue on Nov 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions