Page MenuHomePhabricator

__bit_reference: fix -Wdeprecated-copy warnings

Authored by MaskRay on Dec 5 2019, 4:00 PM.



Since C++11, [depr.impldec]:

The implicit definition of a copy constructor as defaulted is deprecated
if the class has a user-declared copy assignment operator or a
user-declared destructor.

At clang HEAD, -Wdeprecated-copy (included by -Wextra) will warn on such instances.

Diff Detail

Event Timeline

MaskRay created this revision.Dec 5 2019, 4:00 PM

Yes. It fixes the warnings, when I run ninja all with a latest clang. Thankfully there are not too many #include <bitset> in the llvm code base, so the warnings are not overwhelming.

/b/sanitizer-x86_64-linux/build/llvm-project/libcxx/include/bitset:628:17: note: in implicit copy constructor for 'std::__1::__bit_reference<std::__1::__bitset<0, 0>, true>' first required here
        {return reference(0, 1);}
MaskRay marked 2 inline comments as done.Dec 12 2019, 10:04 AM
MaskRay added inline comments.

I guess this file needs to be C++03 compatible, so I don't use = default.


It seems this isn't defined, so I just delete it.

dblaikie added inline comments.

Perhaps it was intended to be declared-but-not-defined to disable the use of copy assignment for this type? (in the days before "= delete" this is how things were done - declare the function privately without a definition)

LGTM given the use of = default and = delete.


= default is C++03 compatible because we allow extensions.

Please go back to using = default.


Yes, please = delete this.

(As mentioned above = delete can be used in C++03 as well).

EricWF accepted this revision.Dec 12 2019, 4:12 PM

LGTM once the changes land. Let's shut this warning up.

This revision is now accepted and ready to land.Dec 12 2019, 4:12 PM
EricWF added inline comments.Dec 12 2019, 4:13 PM

Oh, you'll have to = default the copy constructor for __bit_const_reference after doing this.

MaskRay updated this revision to Diff 233706.Dec 12 2019, 4:27 PM
MaskRay marked 4 inline comments as done.

Use = default and = delete;

This revision was automatically updated to reflect the committed changes.