On Fri, 14 Nov 2025 13:31:15 GMT, Almaz <[email protected]> wrote:

> > For what it's worth, I think the described behavior is non-conforming to 
> > the C standards before C23
> 
> The standard was ambiguous prior to that and 
> https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2293.htm is a good read on 
> that topic.
> 
> Modified test works with initialized segments and there [allocated 
> size](https://github.com/openjdk/jdk/blob/0671309de530822cc261e8251fc425c8aa3cc487/src/java.base/share/classes/jdk/internal/foreign/SegmentFactories.java#L194)
>  is at least 8 bytes. Allocating non-initialized segments of smaller sizes 
> might also help to reveal alignment related bugs. Does it worth adding test 
> like
> 
> ```
>         int[] alignments = {2, 4, 8, 16};
> 
>         try (Arena arena = Arena.ofConfined()) {
>             for (int alignment : alignments) {
>                 var seg = 
> arena.allocateFrom(JAVA_BYTE.withByteAlignment(alignment), (byte) 0);
>                 assertTrue(seg.address() % alignment == 0);
>             }
>         }
> ```
> 
> in this PR?

I think it might be a good idea, yes.

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

PR Comment: https://git.openjdk.org/jdk/pull/28235#issuecomment-3533120342

Reply via email to