Hi,

Valgrind complains about an uninitialized variable in method.c
(implicitly_declare_fn):  

==19553== Conditional jump or move depends on uninitialised value(s)
==19553==    at 0x63D248: implicitly_declare_fn(special_function_kind, 
tree_node*, bool, tree_node*, tree_node*) (method.c:1623)
==19553==    by 0x63EA8F: lazily_declare_fn(special_function_kind, tree_node*) 
(method.c:1894)
==19553==    by 0x6455EC: lookup_fnfields_1(tree_node*, tree_node*) 
(search.c:1441)
==19553==    by 0x64577B: lookup_fnfields_slot(tree_node*, tree_node*) 
(search.c:1471)
==19553==    by 0x64931B: lookup_field_r(tree_node*, void*) (search.c:1031)
==19553==    by 0x645B08: dfs_walk_all(tree_node*, tree_node* (*)(tree_node*, 
void*), tree_node* (*)(tree_node*, void*), void*) (search.c:1572)
==19553==    by 0x645D5D: lookup_member(tree_node*, tree_node*, int, bool, int) 
(search.c:1204)
==19553==    by 0x646010: lookup_fnfields(tree_node*, tree_node*, int) 
(search.c:1295)
==19553==    by 0x4E6E50: build_special_member_call(tree_node*, tree_node*, 
vec<tree_node*, va_gc, vl_embed>**, tree_node*, int, int) (call.c:7282)
==19553==    by 0x4E0DEA: convert_like_real(conversion*, tree_node*, 
tree_node*, int, int, bool, bool, int) (call.c:5718)
==19553==    by 0x4E28D0: build_over_call(z_candidate*, int, int) (call.c:6867)
==19553==    by 0x4E5C28: build_new_method_call(tree_node*, tree_node*, 
vec<tree_node*, va_gc, vl_embed>**, tree_node*, int, tree_node**, int) 
(call.c:7668)
==19553==

The fix is trivial. I would appreciate if someone could commit this.
Thanks.

Bootstrapped and tested on x86_64-pc-linux-gnu.

2012-11-22  Markus Trippelsdorf  <mar...@trippelsdorf.de>

        PR c++/55418
        * method.c (implicitly_declare_fn): Properly initialize trivial_p.

diff --git a/gcc/cp/method.c b/gcc/cp/method.c
index 6dcb63a..778daa8 100644
--- a/gcc/cp/method.c
+++ b/gcc/cp/method.c
@@ -1518,7 +1518,6 @@ implicitly_declare_fn (special_function_kind kind, tree 
type,
   tree name;
   HOST_WIDE_INT saved_processing_template_decl;
   bool deleted_p;
-  bool trivial_p;
   bool constexpr_p;
 
   /* Because we create declarations for implicitly declared functions
@@ -1597,12 +1596,13 @@ implicitly_declare_fn (special_function_kind kind, tree 
type,
   tree inherited_base = (inherited_ctor
                         ? DECL_CONTEXT (inherited_ctor)
                         : NULL_TREE);
+  bool trivial_p = false;
+
   if (inherited_ctor && TREE_CODE (inherited_ctor) == TEMPLATE_DECL)
     {
       /* For an inheriting constructor template, just copy these flags from
         the inherited constructor template for now.  */
       raises = TYPE_RAISES_EXCEPTIONS (TREE_TYPE (inherited_ctor));
-      trivial_p = false;
       deleted_p = DECL_DELETED_FN (DECL_TEMPLATE_RESULT (inherited_ctor));
       constexpr_p
        = DECL_DECLARED_CONSTEXPR_P (DECL_TEMPLATE_RESULT (inherited_ctor));
-- 
Markus

Reply via email to