Skip to content

Templated no-parameter constructor does not mask implicit default constructor #1265

@davmac314

Description

@davmac314

Describe the bug
A templated constructor taking no parameters does not mask the implicit default constructor as it should. CDT still allows calls to the implicit default constructor without highlighting an error. This also has implications for SFINAE as the example below shows; a call to the default constructor should trigger substitution failure, but doesn't.

To Reproduce

class Foo {
public:
    template <typename T> Foo() {}
};

template <typename T, typename U>
struct Bar {
    constexpr static int val = 99;
};

template <typename T>
struct Bar<T, decltype(T())> {
    // no val member
};

constexpr int v = Bar<Foo,Foo>::val; // incorrectly marked with error

Expected behavior
The final line should not be marked as an error (SFINAE should prevent the partial specialisation of Bar from being used in the expression, and the default Bar has the requested variable).

Version Information (please complete the following information):

  • OS: Linux but N/A
  • Eclipse Version: 2025-06 (4.36)
  • CDT Version: 12.1.0.202506041907

Additional context
N/A

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions