C++ PATCH: Avoid wild reads

Nathan Sidwell nathan@codesourcery.com
Thu Jan 11 04:55:00 GMT 2001


Mark Mitchell wrote:
> 
> Jeffrey Oldham figured out that we were touching uninitialized memory
> in instantiate_template:
> 
>   for (clone = TREE_CHAIN (gen_tmpl);
>        clone && DECL_CLONED_FUNCTION_P (clone);
>        clone = TREE_CHAIN (clone))
> 
> Here, the clone can be something like a VAR_DECL that doesn't have a
> full lang_decl, and therefore DECL_CLONED_FUNCTION_P doesn't make
> sense.
This fixes bug 1551, which I was just about to bash on.

I've installed the attached testcase from bug 1551.

nathan

-- 
Dr Nathan Sidwell   ::   http://www.codesourcery.com   ::   CodeSourcery LLC
         'But that's a lie.' - 'Yes it is. What's your point?'
nathan@codesourcery.com : http://www.cs.bris.ac.uk/~nathan/ : nathan@acm.org
// Build don't link:

// Copyright (C) 2000 Free Software Foundation, Inc.
// Contributed by Nathan Sidwell 11 Jan 2001 <nathan@codesourcery.com>

// Bug 1551. We were accessing some uninitialized memory, causing us
// to reject this.

template <typename T>
struct base
{
base();
base(unsigned);
};

template <typename V>
struct Y
{
Y(unsigned = 0);
};

template <>
Y<char>::Y(unsigned) { }

base<double> x;


More information about the Gcc-patches mailing list