[Bug c++/86373] New: Destructor shall not be instantiated in C++17 mode for prvalue
antoshkka at gmail dot com
gcc-bugzilla@gcc.gnu.org
Mon Jul 2 11:40:00 GMT 2018
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86373
Bug ID: 86373
Summary: Destructor shall not be instantiated in C++17 mode for
prvalue
Product: gcc
Version: 9.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: antoshkka at gmail dot com
Target Milestone: ---
Following program fails to compile in -std=c++17 mode
struct some {
some() = default;
~some() = delete;
};
some foo() {
return {};
}
More realistic example:
#include <memory>
struct some;
std::unique_ptr<some> f() {
return {};
}
Output:
/opt/compiler-explorer/gcc-8.1.0/include/c++/8.1.0/bits/unique_ptr.h:79:16:
error: invalid application of 'sizeof' to incomplete type 'some'
static_assert(sizeof(_Tp)>0,
However [basic.lval] say "The result object of a prvalue is the object
initialized by the prvalue; a prvalue that is used to compute the value of an
operand of an operator or that has type (possibly cv-qualified) void has no
result object."
So looks like std::unique_ptr<some> has no object here, so the destructor shall
not be instantiated.
Clang compiles both of the above examples.
More information about the Gcc-bugs
mailing list