Minecraft wiki entry for Bed, associated text: When a player wakes up, if there is two blocks or more space above the bed then the player can wake up on the bed. If there is less than two blocks above the bed and there is space on the side then the player wakes up on the side. If there is no space on the side of the bed and there is less than two blocks above the bed then the player still wakes up on top of the bed, but suffocates if it's a solid block.