As long as USCIS receives your application to extend or change nonimmigrant status on/before the expiration date of your current status, you stay in US is legal. If there is a gap between your old status and new status, you don't have any status in the gap. However, you can stay in US legally.
According to my understanding, if your application to extend or change status is denied, your illegal stay will begin on the expiration date of your old nonimmigrant status.
It is very helpful to have a little knowledge when you deal with your status.