Skip to content

A conversion function template shall not have a deduced return type #51776

@llvmbot

Description

@llvmbot
Bugzilla Link 52434
Version trunk
OS Windows NT
Reporter LLVM Bugzilla Contributor
CC @zygoloid

Extended Description

This code is invalid:

struct S {
    template<class=void>
    operator auto() const { return 2; }
};

int main() {
    S s;
    [[maybe_unused]] int d = s;
}

because the standard explicitly prohibits conversion function template having a deduced return type:
https://timsong-cpp.github.io/cppwp/n4861/class.conv.fct#6

But now Clang accepts the program:
https://gcc.godbolt.org/z/rMK4zboEd
which is a bug.

Metadata

Metadata

Assignees

No one assigned

    Labels

    accepts-invalidbugzillaIssues migrated from bugzillac++14clang:frontendLanguage frontend issues, e.g. anything involving "Sema"

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions