Daryle Walker wrote:
Since Robert's test involves undefined behavior, it's not portable. The assert may work on his system but may crash & burn on a different environment. The assert didn't help the second user at all. And what happens if the uninitialized variable just happens to match a valid state?
nothing ... the archive would still report as being written correctly and would load correctly too. From the point of view of least surprise at least this is better than writing out rubish, not reporting an error and failing to load it back in. The library would be robust under more circumstances. Is there a compiler that does something bad (silently breaks something) available, where this really is a problem? Most people will assume (yes I know) that testing against the false condition (false, 0, whatever) would be all you would see in the code when testing a boolean anyway. (David A. even suggested code for serialising based on this stream << (foo?"t":"f") so I don't feel too bad saying this :-) Maybe under optimisation the alternate behaviour testing against true might mean the compiler decides that the whole assert in this case must be a tautology and eliminate it, but I'd only expect this under a release build which would not have the assert code anyway. me-thinks there are bigger fish to fry here... Kevin -- | Kevin Wheatley, Cinesite (Europe) Ltd | Nobody thinks this | | Senior Technology | My employer for certain | | And Network Systems Architect | Not even myself |