[flang-commits] [flang] [flang] Modifications to ieee_support_halting (PR #120747)

Peter Klausler via flang-commits flang-commits at lists.llvm.org
Fri Dec 20 10:30:25 PST 2024


klausler wrote:

> I've updated the `SupportHalting` code in file `exceptions.cpp` as below to return `no support` on windows, which should be conservatively correct. If the windows build still fails, or there is a better way to address this issue for windows, please comment. Especially if a simple `#include` or some such will suffice.
> 
> ```
> diff --git a/flang/runtime/exceptions.cpp b/flang/runtime/exceptions.cpp
> index 76f8d5168d7b..b34fcfef2b04 100644
> --- a/flang/runtime/exceptions.cpp
> +++ b/flang/runtime/exceptions.cpp
> @@ -84,6 +84,8 @@ uint32_t RTNAME(MapException)(uint32_t excepts) {
>  // Check if the processor has the ability to control whether to halt or
>  // continue execution when a given exception is raised.
>  bool RTNAME(SupportHalting)(uint32_t except) {
> +  bool result = false;
> +#ifndef _WIN32
>    except = RTNAME(MapException)(except);
>    int currentSet = fegetexcept(), flipSet, ok;
>    if (currentSet & except) {
> @@ -95,7 +97,9 @@ bool RTNAME(SupportHalting)(uint32_t except) {
>      flipSet = fegetexcept();
>      ok |= fedisableexcept(except);
>    }
> -  return ok != -1 && currentSet != flipSet;
> +  result = ok != -1 && currentSet != flipSet;
> +#endif
> +  return result;
>  }
> ```

You might need `[[maybe_unused]]` on the argument, or two definitions of the function (one for windows with no argument name that just returns false).

It might be cleaner to have an `#ifdef _WIN32` at the top of the function, if you have just one function.

If you retain `bool result`, please use braced initialization in the runtime.

https://github.com/llvm/llvm-project/pull/120747


More information about the flang-commits mailing list