You hit it on the head as to why everyone in a vehicle who is armed should inform. The officer may be stopping you on the pretext of speeding or running a stop sign (and maybe the driver actually did both) but the officer may have stopped you regardless of if there was a traffic infraction. Why? Because your car and the folks in it somewhat fit the description of the suspects and their car that was just involved in a violent felony or even because they think the car was stolen (think of the recent screw-up by cops when theuy ran a plate as AZ instead of AR and they pulled the family out at gunpoint because the cops thought the vehicle was stolen). Should your pistol somehow become exposed and you did not notify the officer that you were legally armed - an officer who unbeknownst to you already is hyped up on adrenaline because he thinks he is stopping the bad guys and he is now more so because he saw your gun - oh well...live or die with the consequences. Even if they are stopping you for a mere traffic infraction, if an armed passenger inadvertently expose his firearm it could rapidly become very problematic. My safety is the main reason I, as driver or passenger, always let them know I am armed.
If it is a felony stop, cop aint gonna be walking up to car asking for ID, and telling him you have a gun at that point is a really bad decision.