This is an archive of the discontinued LLVM Phabricator instance.

[Clang] Fix capture of values initialized by bitfields
ClosedPublic

Authored by cor3ntin on Aug 4 2022, 2:05 PM.

Details

Summary

This fixes a regression introduced in 127bf44

Diff Detail

Event Timeline

cor3ntin created this revision.Aug 4 2022, 2:05 PM
Herald added a project: Restricted Project. · View Herald TranscriptAug 4 2022, 2:05 PM
cor3ntin requested review of this revision.Aug 4 2022, 2:05 PM
Herald added a project: Restricted Project. · View Herald TranscriptAug 4 2022, 2:05 PM
Herald added a subscriber: cfe-commits. · View Herald Transcript
aaron.ballman added inline comments.
clang/test/SemaCXX/lambda-expressions.cpp
680 ↗(On Diff #450128)

This still should be accepted -- a is an const int & that was materialized from a temporary and lifetime extended, so it's not a bit-field.

cor3ntin updated this revision to Diff 450138.Aug 4 2022, 2:51 PM

Better approach: revert the whole thing.

This revision was not accepted when it landed; it landed in state Needs Review.Aug 4 2022, 2:58 PM
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.

Thanks for reverting this.
Previous commit broke build of projects using fmt library.
https://github.com/fmtlib/fmt/blame/master/include/fmt/format.h

fmt/fmt/include/fmt/format.h:1904:9: error: cannot capture a bit-field by reference
     if (sign) *it++ = detail::sign<Char>(sign);
         ^
 fmt/fmt/include/fmt/format.h:1814:8: note: 'sign' declared here
   auto sign = fspecs.sign;
        ^
 fmt/fmt/include/fmt/core.h:2741:10: note: bit-field is declared here
   sign_t sign : 8;