This is an archive of the discontinued LLVM Phabricator instance.

Address of bitfield in anonymous struct doesn't error.
ClosedPublic

Authored by jacobly on Nov 30 2016, 9:25 AM.

Details

Summary
struct A {
  struct {
    int B : 1;
  }
}
int A::*addr_anon_bitfield() {
    return &A::B;
}

This code does not error, but instead returns a member pointer to a full int that starts at the beginning of the byte the bitfield starts on.

Diff Detail

Repository
rL LLVM

Event Timeline

jacobly updated this revision to Diff 79759.Nov 30 2016, 9:25 AM
jacobly retitled this revision from to Address of bitfield in anonymous struct doesn't error..
jacobly updated this object.
jacobly added a subscriber: cfe-commits.
rsmith accepted this revision.Nov 30 2016, 9:49 AM
rsmith added a reviewer: rsmith.
This revision is now accepted and ready to land.Nov 30 2016, 9:49 AM
This comment was removed by jacobly.
jacobly added a comment.EditedApr 13 2017, 10:38 AM

I don't have commit access, could someone commit this for me?

This revision was automatically updated to reflect the committed changes.

The change to test/SemaCXX/anonymous-struct.cpp appeared to be unrelated to the rest of the patch, so I committed it separately as r300266.

Thank you!