From 4269ec30f85b67bb6fac8bd8fc6b7014a30f85bc Mon Sep 17 00:00:00 2001 From: Thibault Martin <thi.martin.pro@pm.me> Date: Tue, 5 Nov 2024 10:06:18 +0100 Subject: [PATCH] [cabs2cil] Fix wrong initializer check for MSVC --- src/kernel_internals/typing/cabs2cil.ml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/kernel_internals/typing/cabs2cil.ml b/src/kernel_internals/typing/cabs2cil.ml index 60437e0033..5afec74216 100644 --- a/src/kernel_internals/typing/cabs2cil.ml +++ b/src/kernel_internals/typing/cabs2cil.ml @@ -3210,7 +3210,10 @@ let rec collectInitializer | _ -> abort_context "Can initialize only one field for union" in - if Machine.msvcMode () && !pMaxIdx != 0 then + (* CompoundPre is initialized with pMaxId = -1 for empty compound init + (cf. empty_preinit), so we need to check if it is greater than 0 + instead of different. *) + if Machine.msvcMode () && !pMaxIdx > 0 then Kernel.warning ~current:true "On MSVC we can initialize only the first field of a union"; let init, reads = findField 0 (Option.value ~default:[] comp.cfields) in -- GitLab