Looks like a bug to me. I would think that we'd need a separate flag that says whether or not any valid flag characters were seen, and if that flag isn't set outside the loop, then select a suitable default. Relying on a particular default value seems faulty.