C++ exception handling on PPC with gcc 6.4.0 doesn't work

Andreas Falkenhahn andreas at falkenhahn.com
Tue Jun 25 14:44:39 UTC 2024


I've done some more investigation and actually, generally speaking C++ exceptions do seem to work on PPC but for some reason not always. I experienced some rather strange behaviour, e.g.

  // this throw() worked correctly
  throw(0);
  if (_config->isInited) return {};

  // this throw() didn't work and caused a program freeze
  if (_config->isInited) return {};
  throw(0);

The next thing I tried was turning the optimizer off (previously I was always compiling with -O2). Interestingly, turning the optimizer off solved the problem. When compiling without -O2 exceptions seem to work fine and there is no strange behaviour any longer but even using the lowest level of optimization, i.e. just -O, will bring the problems back. 

So the good news is that I've found a workaround. Turning the optimizer off will make exceptions work again but the bad news is that of course it looks like there is some major issue in the optimizer because enabling it seems to break exceptions...

FWIW, I've also tried gcc-mp-7 (MacPorts gcc7 7.5.0_4) which AFAICS is the most recent gcc available for PPC but it shows the same behaviour.

On 27.05.2024 at 18:46 Ken Cunningham wrote:

> do exceptions work with the default gcc7 compiler?



More information about the macports-users mailing list