What counts as a bedroom?

I believe in many cities the standard for being allowed to call something a “bedroom” (for, e.g., real estate listings), is as felixcat describes it: a room with a closet and a window for someone to dash out of in an emergency. There might be different standards for old buildings in places like New York.