Strange enum type conversion
John (Eljay) Love-Jensen
eljay@adobe.com
Thu Dec 3 14:15:00 GMT 2009
Hi Andrew,
> Yes, but there are a fair few loop optimizations that are disabled by
> -fwrapv, so in general it's much better to write in C, not some semi-
> broken version of it.
I heartily agree! My apologies to everyone if I appeared to be advocating
otherwise.
I would not use -fwrapv, nor do I advocate the use of it to avoid the
surprise. Rather, I strongly discourage the use of -fwrapv.
Instead of using a -f<something> as a workaround for bad code, I suggest to
the surprised developer to take the opportunity to learn from the surprise,
and (as per Brian Marshall) write in C to avoid such undefined behaviors.
That being said, C has a lot of sharp edges and dusty corners. Ditto for
C++. Plenty of opportunities to learn from.
(This is not a slam against C or C++. Bad code can be written in any
language.)
Sincerely,
--Eljay
More information about the Gcc-help
mailing list