When generating a fossil feature the structure is placed at a random position in the chunk. However this position never includes the far east and south blocks in that chunk (chunk coordinates X=15 or Z=15). This is most obvious when generating structures with size 15x15 as those are always placed at chunk coordinate 0, 0 leaving a one block gap.
[media](Note that the placement in a grid is not a bug as the feature explicitly makes sure that the structures do not cross chunk boundaries.)
How to reproduce:
Create a world with the attached datapack
Teleport to a savanna
Go into spectator mode and fly downwards
You will see the structures as in the image above
(Note that while this reproduction involves a datapack the bug also affects the vanilla fossils, although its much less obvious because of their smaller size and rarity)
Code analysis:
(using the official mappings and some variable renaming)
The position to place the structure in the chunk is calculated by
{color:#cc7832}int {color}x = random.nextInt({color:#6897bb}16 {color}- size.getX()){color:#cc7832};
{color}{color:#cc7832}int {color}z = random.nextInt({color:#6897bb}16 {color}- size.getZ()){color:#cc7832};{color}
However, as the upper bound of random.nextInt is exclusive, the maximum value of x is 16 - size.getX() - 1. The structure would then reach to x + size.get(X) - 1 = 16 - 1 - 1 = 14
Not fixed in 1.18 Pre-release 1.
1.18 Pre-release 1 added an in_square placement modifier. However this simply caused MC-241234. If (in a datapack), this placement modifier is not used, the fossil feature still does it's own placement inside the chunk, but is still unable to generate in the far east or south blocks of the chunk.
I've attached an updated Datapack to confirm this. This datapack generated two different fossil features in two layers.
The bottom layer around Y=-30 generates fossils of size 15x15 to show the same issue still exists
[media]The top layer around Y=30 generates fossils of size 10x10, to show that this isn't simply the case because of the missing in_square placement modifier.
[media]