[Interest] to -fno-exceptions or not ...

Thiago Macieira thiago.macieira at intel.com
Wed Dec 10 19:24:56 CET 2014

On Wednesday 10 December 2014 14:24:03 René J.V. Bertin wrote:
> Hello,
> After configuring Qt 4.8.6 without any specific options, a message is
> printed suggesting that one may want to re-run the process passing
> -fno-exceptions to the compiler, in order to reduce memory usage (and I
> suppose some processing overhead too). IIRC, I followed that advice once,
> and ended up with mkspecs that added the option to the standard compiler
> flags, which of course causes problems with applications that do use
> exceptions.
> So...
> - Can Qt4 really be built without using exceptions internally without
> side-effects on dependent software? 

Yes. All modules except for QtXmlPatterns (which was contributed code) compile 
without exception support.

> - If so, how?

Set the flag. I'm not sure if you'll have problems with QtXmlPatterns, but I 
don't think you will.

> - How up-to-date is that message about the supposed advantages?

It is up to date.

> - Is this even relevant when using clang (3.5)?

Yes. Note we're talking about memory usage, not about code execution 
performance. The exceptional code paths and the exception tables need to be 
loaded in memory, even if you never use them. And since Qt does not ever use 
them nor marks its routines with the noexcept keyword in Qt 4, all of that is 
most definitely unnecessary.

Qt 5 made the option of compiling all modules except for QtCore and 
QtXmlPatterns without exceptions. QtCore is compiled with it only so that we 
can print some warnings in case you do throw.

Thiago Macieira - thiago.macieira (AT) intel.com
  Software Architect - Intel Open Source Technology Center

More information about the Interest mailing list