File 0304-erts-Fix-possible-Visual-Studio-bug.patch of Package erlang

From 5ae43c5cd0b737121aa1ca0a709a458b4ea2bd3f Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Lukas=20Backstr=C3=B6m?= <lukas@erlang.org>
Date: Fri, 1 Nov 2024 16:01:39 +0100
Subject: [PATCH 3/4] erts: Fix possible Visual Studio bug

Visual Studio 17 seems to compile the original code
into something that make coverage into MAX_SMALL
instead of coverage_data. Extracting the data into
a variable seems to fix the error, don't know why
but hopefully it will be fixed in the compiler someday.
Or maybe the original code is somesort of undefined
behaviour I'm unable to see.

The original code compiles as it should in Visual Studio 14.
---
 erts/emulator/beam/erl_bif_coverage.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/erts/emulator/beam/erl_bif_coverage.c b/erts/emulator/beam/erl_bif_coverage.c
index 0ff51b8de0..6c508b7115 100644
--- a/erts/emulator/beam/erl_bif_coverage.c
+++ b/erts/emulator/beam/erl_bif_coverage.c
@@ -374,6 +374,7 @@ get_cover_id_line(Process* c_p, const BeamCodeHeader* hdr)
     for (i = hdr->line_coverage_len - 1; i >= 0; i--) {
         Eterm coverage = am_error;
         Uint* coverage_array = hdr->coverage;
+        Sint coverage_data;
         unsigned cover_id;
 
         if (!hdr->line_coverage_valid[i]) {
@@ -388,7 +389,8 @@ get_cover_id_line(Process* c_p, const BeamCodeHeader* hdr)
         if (location == LINE_INVALID_LOCATION) {
             continue;
         }
-        coverage = make_small(MIN(coverage_array[i], MAX_SMALL));
+        coverage_data = coverage_array[i];
+        coverage = make_small(MIN(coverage_data, MAX_SMALL));
         cover_id = loc2id[i];
         tmp = TUPLE2(hp, make_small(cover_id), coverage);
         hp += 3;
-- 
2.43.0

openSUSE Build Service is sponsored by