LWN.net Logo

C vs. C++ vs. ...

C vs. C++ vs. ...

Posted Jul 4, 2012 15:08 UTC (Wed) by nix (subscriber, #2304)
In reply to: C vs. C++ vs. ... by jwakely
Parent article: Why learn C? (O'Reilly Radar)

Oooh. Interesting. Given that 99% of C libraries are not compiled with -fexceptions and do not specify anything nothrow-related in their prototypes (of course not, they're C), this suggests that G++ is introducing a very large number of unnecessary abnormal edges for exceptions potentially raised in calls to such functions that cannot possibly ever be thrown. I wonder how much this is impairing optimization?


(Log in to post comments)

C vs. C++ vs. ...

Posted Jul 4, 2012 15:51 UTC (Wed) by scottt (subscriber, #5028) [Link]

> Given that 99% of C libraries are not compiled with -fexceptions

Note that Red Hat and Fedora has been building the whole distro with -fexceptions for years:

rpmbuild --showrc | grep cflags
-14: __global_cflags	-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions <...>
I suspect other distros do the same.

C vs. C++ vs. ...

Posted Jul 4, 2012 18:43 UTC (Wed) by jwakely (subscriber, #60262) [Link]

Doesn't the stack have to be unwound similarly for thread cancellation?

The C frames don't need to do any cleanup (no destructors) and should just let the exception propagate unhindered, until it reaches a frame with the right C++ personality to handle it.

I might be completely wrong, but I don't see any obvious reasons the generated code should be different.

Copyright © 2013, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds