Skip to content
Snippets Groups Projects
Commit 7d3a3b9d authored by Forget Julien's avatar Forget Julien
Browse files

Bug fix: print_array_litteral cannot be used to initialize

unsized arrays. This caused a bug with communication protocols, I added
array lengths in struct initialization to fix this.


git-svn-id: https://svn.onera.fr/Prelude/Prelude/trunk@901 49f62630-d767-4ccd-930e-b3f5589f52e1
parent 0093829b
No related branches found
No related tags found
No related merge requests found
......@@ -169,7 +169,7 @@ let pp_proto_struct out_f struct_type proto_name no_init tid vid pref pat =
(* Prefix *)
if pref_length > 0 then
begin
fprintf out_f "(int[])";
fprintf out_f "(int[%d])" pref_length;
print_array_litteral out_f
(fun out_f v -> fprintf out_f "%s" (cstring_of_bool v))
(cstring_of_bool false)
......@@ -181,7 +181,7 @@ let pp_proto_struct out_f struct_type proto_name no_init tid vid pref pat =
fprintf out_f ", %i, " pref_length;
if pat_length > 0 then
begin
fprintf out_f "(int[])";
fprintf out_f "(int[%d])" pat_length;
print_array_litteral out_f
(fun out_f v -> fprintf out_f "%s" (cstring_of_bool v))
(cstring_of_bool false)
......
......@@ -300,7 +300,9 @@ let pp_bool_include out_f =
(** Prints array litteral (initialization) with values described by
[array]. If the array contains a tail of zeros, replaces the tail by
a single 0. *)
a single 0. Warning, for this to work, the array being initialized
must be declared with the correct size. Initialization of unsized arrays
will cause bugs. *)
let print_array_litteral out_f printer zero_string zero_test array =
let tail_size = zero_tail_size zero_test array in
if tail_size = 0 then
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment