RFR: 8306901: Macro offset_of confuses Eclipse CDT

Richard Reingruber rrich at openjdk.org
Thu Apr 27 07:50: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

Hi Thomas,

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

thanks for the review!

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

Indeed.

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

Probably :)
At least it would be cleaner in my eyes than the hard coded 16.
With this pr I'd like to address just the CDT issue though.

Thanks, Richard.

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

PR Comment: https://git.openjdk.org/jdk/pull/13668#issuecomment-1524999747


More information about the hotspot-dev mailing list