Skip to content

[Clang] Fails to diagnose return; in non-void function in class template #151156

@Xniao

Description

@Xniao

Program

template <class T> struct S {
  T f;
  S() : f() {}
  S foo() {
    return;
  }
};

int main() {
    S<int> f,g;
}

Repro: https://godbolt.org/z/cf7oTvqfa
✅ GCC correctly rejects with a diagnostic.
❌ Clang accepts, unless the function is called.
When the return type of function foo is changed from S to int, Clang does reject the code.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions