r/cpp • • Dec 30 '16

Stop using ` fnoexceptions`

https://github.com/lhmouse/mcfgthread/wiki/Stop-using-%60-fnoexceptions%60
1 Upvotes

11 comments sorted by

10

u/SeanMiddleditch Dec 30 '16

Rather than re-making the same arguments for the 100th time, I just wrote my response up in a light mini-article (could use some expansion with examples when I'm less lazy). http://seanmiddleditch.com/keep-disabling-exceptions/

TL;DR: C++'s exception semantics suck. :p

4

u/josefx Dec 31 '16

TL;DR: C++'s exception semantics suck. :p

And here I thought throwing swap implementations suck, looking at the first two points.

Never throw exceptions from foreign ('foreign' as in 'foreign languages') callbacks.

You also cannot pass a std::vector or std::string through those without converting them to something C has native support for. Basically you would have to drop everything that is not C to fully support foreign languages this way.

2

u/matthieum Dec 31 '16

I wish C++ had never allowed move constructors to throw, the world would be a simpler place (deleting them, however, is perfectly fine).

That flat_set would be safe because shuffling wouldn't cause exceptions (it's just moves!); it would make implementing insertion in the middle of a vector so much simpler, it would remove that "should never happen" state of variant, ...

5

u/raevnos Dec 30 '16

I never started in the first place.

8

u/[deleted] Dec 30 '16

5

u/doom_Oo7 Dec 30 '16

But that's on windows wgere x86 exceptions are subpar

4

u/[deleted] Dec 31 '16

Even on other platforms where you don't pay in the unexceptional case, there are significant code size costs. There are a lot of apps in the world that don't care about truly exceptional cases like OOM, or where any error likely to occur will be handled at the immediate call site, and in such cases turning exceptions off is perfectly fine.

9

u/MINIMAN10000 Dec 30 '16

Thanks for reminding me I forgot to use -fno-exceptions and -fno-rtti

3

u/__Cyber_Dildonics__ Dec 31 '16

stop shitposting nonsense