Commit 014540b2af37ec01c9bbad6f93ed33425fee1101

Thomas de Grivel 2024-08-31T07:08:19

workaround -O1 bug : tag_init_void

diff --git a/libkc3/configure b/libkc3/configure
index 6419637..56c638d 100755
--- a/libkc3/configure
+++ b/libkc3/configure
@@ -73,7 +73,7 @@ LDFLAGS_COV="$LDFLAGS --coverage"
 LIBS_COV="$LIBS -lgcov"
 
 # Debug config
-CFLAGS_DEBUG="$CFLAGS -DDEBUG -O0 -g"
+CFLAGS_DEBUG="$CFLAGS -DDEBUG -O1 -g"
 LDFLAGS_DEBUG="$LDFLAGS"
 LIBS_DEBUG="$LIBS"
 
diff --git a/libkc3/list_init.c b/libkc3/list_init.c
index fe3379a..b84a6e1 100644
--- a/libkc3/list_init.c
+++ b/libkc3/list_init.c
@@ -647,17 +647,6 @@ s_list * list_init_uw (s_list *list, uw i, s_list *next)
   return list;
 }
 
-s_list * list_init_void (s_list *list, s_list *next)
-{
-  s_list tmp = {0};
-  assert(list);
-  list_init(&tmp, next);
-  if (! tag_init_void(&tmp.tag))
-    return NULL;
-  *list = tmp;
-  return list;
-}
-
 s_list * list_new_array (const s_sym *type, uw dimension,
                          const uw *dimensions, s_list *next)
 {
@@ -1357,16 +1346,3 @@ s_list * list_new_uw (uw i, s_list *next)
   }
   return list;
 }
-
-s_list * list_new_void (s_list *next)
-{
-  s_list *list;
-  list = list_new(next);
-  if (! list)
-    return NULL;
-  if (! tag_init_void(&list->tag)) {
-    free(list);
-    return NULL;
-  }
-  return list;
-}
diff --git a/libkc3/tag.c b/libkc3/tag.c
index b8a75f2..73a42dd 100644
--- a/libkc3/tag.c
+++ b/libkc3/tag.c
@@ -596,6 +596,13 @@ s_tag * tag_init_var (s_tag *tag, const s_sym *type)
   return tag;
 }
 
+s_tag * tag_init_void (s_tag *tag)
+{
+  assert(tag);
+  *tag = (s_tag) {0};
+  return tag;
+}
+
 s_tag * tag_integer_reduce (s_tag *tag)
 {
   s_integer *i;
@@ -1523,6 +1530,14 @@ const s_sym ** tag_var_type (const s_tag *tag, const s_sym **dest)
   return tag_type(tag, dest);
 }
 
+s_tag * tag_void (s_tag *tag)
+{
+  assert(tag);
+  tag_clean(tag);
+  *tag = (s_tag) {0};
+  return tag;
+}
+
 bool tag_xor (const s_tag *a, const s_tag *b)
 {
   s_tag f;
diff --git a/libkc3/tag_init.c b/libkc3/tag_init.c
index f6812b7..c6cdaa8 100644
--- a/libkc3/tag_init.c
+++ b/libkc3/tag_init.c
@@ -624,15 +624,6 @@ s_tag * tag_init_uw (s_tag *tag, uw i)
   return tag;
 }
 
-s_tag * tag_init_void (s_tag *tag)
-{
-  s_tag tmp = {0};
-  assert(tag);
-  tmp.type = TAG_VOID;
-  *tag = tmp;
-  return tag;
-}
-
 s_tag * tag_new_array (const s_sym *type, uw dimension,
                        const uw *dimensions)
 {
@@ -1338,16 +1329,6 @@ s_tag * tag_new_uw (uw i)
   return tag;
 }
 
-s_tag * tag_new_void (void)
-{
-  s_tag *tag;
-  tag = alloc(sizeof(s_tag));
-  if (! tag)
-    return NULL;
-  tag->type = TAG_VOID;
-  return tag;
-}
-
 s_tag * tag_array (s_tag *tag, const s_sym *type, uw dimension,
                    const uw *dimensions)
 {
@@ -1983,13 +1964,3 @@ s_tag * tag_uw (s_tag *tag, uw i)
   *tag = tmp;
   return tag;
 }
-
-s_tag * tag_void (s_tag *tag)
-{
-  s_tag tmp = {0};
-  assert(tag);
-  tag_clean(tag);
-  tmp.type = TAG_VOID;
-  *tag = tmp;
-  return tag;
-}
diff --git a/libkc3/tag_init.rb b/libkc3/tag_init.rb
index 63e6f58..1f1e262 100644
--- a/libkc3/tag_init.rb
+++ b/libkc3/tag_init.rb
@@ -424,7 +424,7 @@ class TagInitList
                    [Arg.new("uw", "i")]),
        TagInitProto.new("var", "TAG_VAR", :init_mode_none,
                    [Arg.new("const s_sym *", "type")]),
-       TagInit.new("void", "TAG_VOID", :init_mode_none, [])])
+       TagInitProto.new("void", "TAG_VOID", :init_mode_none, [])])
   end
 
   def initialize(items)