-
Notifications
You must be signed in to change notification settings - Fork 45
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Don't set subobject bounds on hand-rolled offsetof idioms #608
base: dev
Are you sure you want to change the base?
Conversation
…seExpr It's possible we could do without the QualType out param, but I'm not sure if edge cases where references are involved would be otherwise ambiguous.
Technically this is UB, but it exists in real-world code and it's unnecessarily hostile to break such idioms.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know the LLVM code well enough to review, but the test cases look sensible to me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, but I do wonder why the clang-format check no longer works 😢
E->getDereferencedBaseExpr(getContext())->IgnoreParenCasts(); | ||
if (BaseDeref->isNullPointerConstant(getContext(), | ||
Expr::NPC_ValueDependentIsNotNull)) | ||
return cannotSetBounds(*this, E, Ty, Kind, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if we should be emit a warning and suggest replacing it with (__builtin_)offsetof
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The thought did occur to me but then forgot about it; probably should
Yeah, really odd failure mode |
ping? Should we merge this as-is or are you planning to add the fixit? |
From memory I found a bunch of problems in testing this where it didn’t work for anything non-trivial |
No description provided.