Hello Bruno, all, GCC 4.0.3 and newer (with `-Wall -Werror -fno-builtin' on a GNU/Linux x86_64 system) errors out at some of the list implementation "constructor" functions: | gl_array_list.c: In function ‘gl_array_iterator’: | gl_array_list.c:398: warning: ‘result.j’ is used uninitialized in this function | gl_array_list.c:398: warning: ‘result.i’ is used uninitialized in this function
Now I have a question here: the structures in question are created on the stack, and then passed to the calling function with `return'. Does the return expression count as accessing the value of the automatic object? Because if it does, then I read C99 6.2.6.1(5) and footnote 41 such that the values have to be initialized, if we want to avoid undefined behavior: the variables could otherwise contain trap representations. Am I reading this wrongly? If not: ok to apply? Cheers, Ralf * gl_anylinked_list2.h (gl_linked_iterator) (gl_linked_iterator_from_to): Initialize struct completely. * gl_anytree_list2.h (gl_tree_iterator): Likewise. (gl_tree_iterator_from_to): Likewise * gl_anytree_oset.h (gl_tree_iterator): Likewise. * gl_array_list.c (gl_array_iterator) (gl_array_iterator_from_to) : Likewise. * gl_array_oset.c (gl_array_iterator): Likewise. * gl_carray_list.c (gl_carray_iterator) (gl_carray_iterator_from_to): Likewise. Index: lib/gl_anylinked_list2.h =================================================================== RCS file: /cvsroot/gnulib/gnulib/lib/gl_anylinked_list2.h,v retrieving revision 1.2 diff -u -r1.2 gl_anylinked_list2.h --- lib/gl_anylinked_list2.h 24 Jul 2006 16:34:38 -0000 1.2 +++ lib/gl_anylinked_list2.h 22 Sep 2006 05:10:20 -0000 @@ -697,6 +697,9 @@ result.list = list; result.p = list->root.next; result.q = &list->root; + result.i = 0; + result.j = 0; + result.count = 0; return result; } @@ -763,6 +766,10 @@ result.q = node; } + result.i = 0; + result.j = 0; + result.count = 0; + return result; } Index: lib/gl_anytree_list2.h =================================================================== RCS file: /cvsroot/gnulib/gnulib/lib/gl_anytree_list2.h,v retrieving revision 1.1 diff -u -r1.1 gl_anytree_list2.h --- lib/gl_anytree_list2.h 17 Jul 2006 11:27:18 -0000 1.1 +++ lib/gl_anytree_list2.h 22 Sep 2006 05:10:20 -0000 @@ -349,6 +349,9 @@ result.p = node; /* End point is past the rightmost node. */ result.q = NULL; + result.i = 0; + result.j = 0; + result.count = 0; return result; } @@ -368,6 +371,9 @@ result.p = (start_index < count ? node_at (list->root, start_index) : NULL); /* End point is the node at position end_index. */ result.q = (end_index < count ? node_at (list->root, end_index) : NULL); + result.i = 0; + result.j = 0; + result.count = 0; return result; } Index: lib/gl_anytree_oset.h =================================================================== RCS file: /cvsroot/gnulib/gnulib/lib/gl_anytree_oset.h,v retrieving revision 1.1 diff -u -r1.1 gl_anytree_oset.h --- lib/gl_anytree_oset.h 17 Jul 2006 11:27:35 -0000 1.1 +++ lib/gl_anytree_oset.h 22 Sep 2006 05:10:20 -0000 @@ -211,6 +211,9 @@ result.p = node; /* End point is past the rightmost node. */ result.q = NULL; + result.i = 0; + result.j = 0; + result.count = 0; return result; } Index: lib/gl_array_list.c =================================================================== RCS file: /cvsroot/gnulib/gnulib/lib/gl_array_list.c,v retrieving revision 1.2 diff -u -r1.2 gl_array_list.c --- lib/gl_array_list.c 14 Sep 2006 14:18:36 -0000 1.2 +++ lib/gl_array_list.c 22 Sep 2006 05:34:34 -0000 @@ -394,6 +394,8 @@ result.count = list->count; result.p = list->elements + 0; result.q = list->elements + list->count; + result.i = 0; + result.j = 0; return result; } @@ -411,6 +413,8 @@ result.count = list->count; result.p = list->elements + start_index; result.q = list->elements + end_index; + result.i = 0; + result.j = 0; return result; } Index: lib/gl_array_oset.c =================================================================== RCS file: /cvsroot/gnulib/gnulib/lib/gl_array_oset.c,v retrieving revision 1.2 diff -u -r1.2 gl_array_oset.c --- lib/gl_array_oset.c 14 Sep 2006 14:18:36 -0000 1.2 +++ lib/gl_array_oset.c 22 Sep 2006 05:10:20 -0000 @@ -229,6 +229,8 @@ result.count = set->count; result.p = set->elements + 0; result.q = set->elements + set->count; + result.i = 0; + result.j = 0; return result; } Index: lib/gl_carray_list.c =================================================================== RCS file: /cvsroot/gnulib/gnulib/lib/gl_carray_list.c,v retrieving revision 1.2 diff -u -r1.2 gl_carray_list.c --- lib/gl_carray_list.c 14 Sep 2006 14:18:36 -0000 1.2 +++ lib/gl_carray_list.c 22 Sep 2006 05:10:20 -0000 @@ -528,6 +528,8 @@ result.count = list->count; result.i = 0; result.j = list->count; + result.p = 0; + result.q = 0; return result; } @@ -545,6 +547,8 @@ result.count = list->count; result.i = start_index; result.j = end_index; + result.p = 0; + result.q = 0; return result; }