Skip to content

Passing templated function-local class as template parameter causes infinite recursion in instantiation #48183

@MitalAshok

Description

@MitalAshok
Bugzilla Link 48839
Version trunk
OS All
CC @DougGregor,@futog,@zygoloid

Extended Description

The following compiles with gcc but does not with clang:

    template<typename T>
    void construct() {
        T(0);
    }

    template<typename T>
    void tester() {
        struct d {
            void test() {
                construct<d>();
            }
            constexpr d(T b) : a(b) {}
            T a;
        };
    }

    int main() {
        tester<int>();
    }

link: https://godbolt.org/z/jd41rr

It fails with "fatal error: recursive template instantiation exceeded maximum depth of 1024"

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugzillaIssues migrated from bugzillac++clang:frontendLanguage frontend issues, e.g. anything involving "Sema"confirmedVerified by a second party

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions