Windows 10, running MC Java 1.14. Java 1.8.0_51
Golems - or any mob - can not spawn with their bounding box intersecting any block they could not pass through once spawned.
Iron Golems will currently spawn occupying the same space as a block they would not normally be able to walk through, and are then stuck there as the block still prevents them from walking through it. This is most noticeable in compact villages, as the golems can spawn on the block below a bed, and are then stuck on the spot. This makes it very difficult to ensure that golems do not spawn inside village buildings they cannot escape.
The same is true of stairs. The cannot spawn on the stairs, as they are not considered to have a soid top surface, but they can spawn through them, placed on the block below, and are then occupying the same space as the stair block and are locked in place by it.
Steps to duplicate:
Create a super-compact village in creative mode by placing beds and workstations ina small walled off area. surround the area with beds and/or stair blocks. Golems will spawn on the solid blocks below the beds and/or stairs.
An screenshot is attached showing two such stuck golems, in this case standing on blocks below stairs which are in turn below beds, so they're buried up to the shoulder in solid opbjects which makes no sense.
Suggested remedial action:
Modify the spawn success/fail check to ensure there is only air or water within the potential golem's bounding box, rather than the current check which appears to only ensure there are no blocks with a fully solid top surface.
MC-147212 Iron golems can spawn in spaces less than three blocks high and get stuck