cplusplus / CWG

Core Working Group
23 stars 7 forks source link

[expr.prim.lambda.closure] p16 All major implementations don't adhere the rule #396

Closed xmh0511 closed 1 year ago

xmh0511 commented 1 year ago

Full name of submitter (unless configured in github; will be published with the issue): Jim X

[expr.prim.lambda.closure] p16

A member of a closure type shall not be explicitly instantiated, explicitly specialized, or named in a friend declaration.

IIUC, this rule just prohibit the user-defined specialization for the function call operator template of a lambda-expression. Consider this example:

auto f(){
    return [](auto c)->void{};
}

using Closure = decltype(f());

template<>
void Closure::operator()<int>(int) const{ }

All major implementations(i.e. Clang, GCC, and MSVC) accept this example, see https://godbolt.org/z/WsGsGWv6c. Is this a bug of these vendor implementations, or the wording is outdated?

frederick-vs-ja commented 1 year ago

The prohibition is intended, see CWG1780. And I think it's better to report this as compiler bugs.

frederick-vs-ja commented 1 year ago

See

I think this issue can be closed as completed.

xmh0511 commented 1 year ago

Thanks. The issue has been confirmed to be a bug in vendor implementations.