From e9b137a428a6be71bf4e2fc46166143da2dd0950 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?David=20B=C3=BChler?= <david.buhler@cea.fr>
Date: Tue, 18 May 2021 09:34:03 +0200
Subject: [PATCH] [kernel] Rejects bitfields with negative width. Avoids later
 crash in analyses.

---
 src/kernel_internals/typing/cabs2cil.ml | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/src/kernel_internals/typing/cabs2cil.ml b/src/kernel_internals/typing/cabs2cil.ml
index 4282f0e9f46..69701e3eda8 100644
--- a/src/kernel_internals/typing/cabs2cil.ml
+++ b/src/kernel_internals/typing/cabs2cil.ml
@@ -5476,6 +5476,8 @@ and makeCompType ghost (isstruct: bool)
               Some 0, ftype
             | Some s as w ->
               begin
+                if s < 0 then
+                  Kernel.error ~current:true "negative bitfield width (%d)" s;
                 try
                   if s > Cil.bitsSizeOf ftype then
                     Kernel.error ~current:true
-- 
GitLab