Bug 94602 - wrong semantic check to prvalue as decltype operand
Summary: wrong semantic check to prvalue as decltype operand
Status: UNCONFIRMED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 9.3.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: rejects-valid
Depends on:
Blocks:
 
Reported: 2020-04-15 06:15 UTC by frankhb1989
Modified: 2020-04-16 19:10 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description frankhb1989 2020-04-15 06:15:34 UTC
Case:

struct S
{
    ~S() = delete;    
};
S f();
int main()
{
    using X = decltype(f()); // #1
    using Y = decltype(S{}); // #2
}

#2 is wrongly rejected in C++17 mode.

#1 is not ill-formed for the deleted destructor as per C++11 [dcl.type.simple]/5:

> ... in the case where the operand of a decltype-specifier
is a function call and the return type of the function is a class type, a special rule (5.2.2) ensures that the return type is not required to be complete (as it would be if the call appeared in a sub-expression or outside of a
decltype-specifier) ... In particular, it is not necessary to allocate storage for a temporary object or to enforce the semantic constraints associated with invoking the type's destructor. ...

This rule is expanded by P0135R1 for cases like #2, which is adopted in C++17.

(See also P0929R2.)