This is an archive of the discontinued LLVM Phabricator instance.

Explicit cast on customized offsetof should not be ignored when evaluating as const
ClosedPublic

Authored by danix800 on Feb 25 2023, 12:44 AM.

Details

Summary

If ignored, the subexpr is a UnaryOperator (&) which cannot be evaluated (assertion failed).

#define offsetof(type,memb) ((unsigned long)&((type*)0)->memb)

Diff Detail

Event Timeline

danix800 created this revision.Feb 25 2023, 12:44 AM
Herald added a project: Restricted Project. · View Herald Transcript
danix800 requested review of this revision.Feb 25 2023, 12:44 AM
steakhal accepted this revision.Feb 27 2023, 1:00 AM

I love it. Short, to the point. Thanks.
I think this is the right way to fix this.
Good job.
Can you merge the change? Or should I do it on you behalf?

This revision is now accepted and ready to land.Feb 27 2023, 1:00 AM

I love it. Short, to the point. Thanks.
I think this is the right way to fix this.
Good job.
Can you merge the change? Or should I do it on you behalf?

I've no permission to merge, please do it for me. Thanks!

I love it. Short, to the point. Thanks.
I think this is the right way to fix this.
Good job.
Can you merge the change? Or should I do it on you behalf?

I've no permission to merge, please do it for me. Thanks!

In that case please tell me what should I set as the commit-author?

danix800 (danix800@gmail.com) is OK, thanks!

This revision was landed with ongoing or failed builds.Mar 6 2023, 11:45 PM
This revision was automatically updated to reflect the committed changes.

Ah sorry that it took me so long to push this. I completely forgot about this one.

As this resolves a crash, I'm backporting it: https://github.com/llvm/llvm-project/issues/61245