RFR: 8306901: Macro offset_of confuses Eclipse CDT

Thomas Stuefe stuefe at openjdk.org
Wed Apr 26 18:39:23 UTC 2023


On Wed, 26 Apr 2023 09:42:52 GMT, Richard Reingruber <rrich at openjdk.org> wrote:

> With this pr I would like to wrap the body of the macro `offset_of` as defined for gcc in parentheses to fix the described issues with Eclipse CDT.
> As an alternative the [`(int)` cast in `byte_offset_of`](https://github.com/openjdk/jdk/blob/44d9f55d0b3c469988be6f1c47f0cfbc433c4490/src/hotspot/share/utilities/sizes.hpp#L59) could be removed. I preferred adding the parentheses to the gcc version of `offset_of` because the impact is smaller.
> 
> Of course I'd rather have a local solution for the issue but I couldn't find one that didn't require changes in the source code.
> 
> Testing: GHA

Looks good. Thanks for fixing this, I had noticed this in CDT myself.

I never looked closely at this macro though. I wish we could just use offsetof. 

Also I wonder whether the ATTRIBUTE_ALIGNED(16) would be more correctly `alignas(klass)` but that is pre-existing.

-------------

Marked as reviewed by stuefe (Reviewer).

PR Review: https://git.openjdk.org/jdk/pull/13668#pullrequestreview-1402562083


More information about the hotspot-dev mailing list