https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94492
Bug ID: 94492
Summary: no way to silence -Wdeprecated-copy for aggregates
Product: gcc
Version: 10.0
Status: UNCONFIRMED
Keywords: diagnostic
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: nok.raven at gmail dot com
Target Milestone: ---
There is no way to silence the warning without making a type non-aggregate.
A simplified case from Boost.Proto:
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdeprecated-copy"
struct expr
{
int a, b;
expr& operator=(const expr&) { return *this; }
};
#pragma GCC diagnostic pop
#include <type_traits>
static_assert(std::is_aggregate_v<expr>);
expr foo(expr e)
{
return e;
}
<source>: In function 'expr foo(expr)':
<source>:15:12: error: implicitly-declared 'constexpr expr::expr(const expr&)'
is deprecated [-Werror=deprecated-copy]
15 | return e;
| ^
<source>:6:11: note: because 'expr' has user-provided 'expr&
expr::operator=(const expr&)'
6 | expr& operator=(const expr&) { return *this; }
| ^~~~~~~~