Skip to content
Snippets Groups Projects
Commit 061b5aa8 authored by Virgile Prevosto's avatar Virgile Prevosto
Browse files

[rte] fatal error if accessing an object whose type is an undefined union

parent 8fa891ec
No related branches found
No related tags found
No related merge requests found
...@@ -111,15 +111,18 @@ let lval_initialized_assertion ~remove_trivial:_ ~on_alarm lv = ...@@ -111,15 +111,18 @@ let lval_initialized_assertion ~remove_trivial:_ ~on_alarm lv =
| NoOffset -> | NoOffset ->
begin begin
match typ with match typ with
| TComp({cstruct = false; cfields} ,_,_) -> | TComp({cstruct = false; cfields; cname} ,_,_) ->
(match cfields with (match cfields with
| Some [] | None -> () (* empty union, supported by gcc with size 0. | None ->
Trivially initialized. *) Options.fatal
| _ -> "Access to an object of undefined union %a"
Printer.pp_varname cname
| Some [] -> () (* empty union, supported by gcc with size 0.
Trivially initialized. *)
| Some l ->
let llv = let llv =
List.map List.map
(fun fi -> Cil.addOffsetLval (Field (fi, NoOffset)) lv) (fun fi -> Cil.addOffsetLval (Field (fi, NoOffset)) lv) l
(Option.get cfields)
in in
if default then if default then
on_alarm ~invalid:false (Alarms.Uninitialized_union llv)) on_alarm ~invalid:false (Alarms.Uninitialized_union llv))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment