UCL / STIR

Software for Tomographic Image Reconstruction
http://stir.sourceforge.net/
Other
108 stars 91 forks source link

Clang 18 on MacOS tests fail due to uncaught (but intentional) exceptions #1490

Open KrisThielemans opened 3 weeks ago

KrisThielemans commented 3 weeks ago

We have a few tests that check if errors are thrown, e.g. https://github.com/UCL/STIR/blob/209cbb634b841300886d431a37d4181188f20743/src/test/test_DateTime.cxx#L105-L114 However, with clang18 on MacOS these tests all fail https://github.com/UCL/STIR/actions/runs/10450627407/job/28935385772?pr=1489#step:12:751

Testing DICOM DateTime to epoch functionality

The next test should throw an error

ERROR: Time_Zone info '+020' does not fit DICOM standard
libc++abi: terminating due to uncaught exception of type std::runtime_error: 
ERROR: Time_Zone info '+020' does not fit DICOM standard

This is pretty weird, at catch (...) should catch all exceptions AFAIK, so this seems like a clang bug to me.

However, we know what we're throwing https://github.com/UCL/STIR/blob/209cbb634b841300886d431a37d4181188f20743/src/buildblock/error.cxx#L62 So we could just as well (or even better) catch std::runtime_error.

KrisThielemans commented 2 weeks ago

Catching std::runtime_error& as in https://github.com/UCL/STIR/pull/1496/files#diff-8edd730b56a9f4c3e9faa36d393762b837fd91893dda5e4db881a97f3a0c5cf4 does not help. https://github.com/UCL/STIR/actions/runs/10545168824/job/29215018326#step:12:119

You should now see an error about a wrong setting for alpha

ERROR: Alpha parameter for ramp has to be between 0 and 1 but is -1
libc++abi: terminating due to uncaught exception of type std::runtime_error: 
ERROR: Alpha parameter for ramp has to be between 0 and 1 but is -1