> Yes, that is right; and printf does tell you, it explicitly prints the
> text (null) to the stdout, and I imagine (but have not tested) that the
> function return value would also signify the fault.
>
> The iostream approach tells you something has happened *if you test the
> badbit* but no signifier appears on the console output, and the stream
> stops outputting until you clear the badbit, so I think that is actually
> less useful in practice than the behaviour exhibited by printf.
>

Just to be clear, the printf semantics and "the iostream approach"
are precisely identical in the context under discussion: their
behavior is undefined.  Specifically, you will not see printf
printing the text (null) on every platform, nor will you see cout's
badbit being set on every platform.  When behavior is undefined,
all bets are off.

The question of whether or not it's useful for a compiler to
do something ostensibly helpful in specific circumstances of
undefined behavior has been debated for a long time, and
it's sort of off-topic here.  That said, if we want to continue
the discussion, it's about "is it a good idea for gcc to do
such-and-such;" it's not about the differences between
printf and ostream.

I hope to be shedding light here, not heat :)

Best,
Stan


_______________________________________________
fltk mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk

Reply via email to