diff --git a/include/openmc/error.h b/include/openmc/error.h index 062368f17..5f30f0252 100644 --- a/include/openmc/error.h +++ b/include/openmc/error.h @@ -7,6 +7,12 @@ #include "openmc/capi.h" +#ifdef __GNUC__ +#define UNREACHABLE() __builtin_unreachable() +#else +#define UNREACHABLE() (void)0 +#endif + namespace openmc { inline void diff --git a/src/nuclide.cpp b/src/nuclide.cpp index 7f034fd41..6094b7983 100644 --- a/src/nuclide.cpp +++ b/src/nuclide.cpp @@ -454,9 +454,7 @@ double Nuclide::nu(double E, EmissionMode mode, int group) const return (*fission_rx_[0]->products_[0].yield_)(E); } } -#ifdef __GNUC__ - __builtin_unreachable(); -#endif + UNREACHABLE(); } void Nuclide::calculate_elastic_xs(Particle& p) const diff --git a/src/physics.cpp b/src/physics.cpp index e28c5a00e..0d0c60343 100644 --- a/src/physics.cpp +++ b/src/physics.cpp @@ -883,9 +883,7 @@ Direction sample_target_velocity(const Nuclide* nuc, double E, Direction u, } // case RVS, DBRC } // switch (sampling_method) -#ifdef __GNUC__ - __builtin_unreachable(); -#endif + UNREACHABLE(); } Direction diff --git a/src/plot.cpp b/src/plot.cpp index 74279cad5..57466eca1 100644 --- a/src/plot.cpp +++ b/src/plot.cpp @@ -693,10 +693,8 @@ void draw_mesh_lines(Plot pl, ImageData& data) outer = 1; inner = 2; break; -#ifdef __GNUC__ default: - __builtin_unreachable(); -#endif + UNREACHABLE(); } Position ll_plot {pl.origin_}; diff --git a/src/tallies/filter_particle.cpp b/src/tallies/filter_particle.cpp index 1d4b84937..23a305b8d 100644 --- a/src/tallies/filter_particle.cpp +++ b/src/tallies/filter_particle.cpp @@ -50,9 +50,7 @@ ParticleFilter::text_label(int bin) const case Particle::Type::positron: return "Particle: positron"; } -#ifdef __GNUC__ - __builtin_unreachable(); -#endif + UNREACHABLE(); } } // namespace openmc