I don't have a test case, but look at the definitions of the two macros in cp/cp-tree.h. DECL_CLONED_FUNCTION_P calls decl_cloned_function_p, passing true as the second argument, while DECL_CLONED_FUNCTION makes the same call, but passes false. Now look at the definition of decl_cloned_function_p in cp/class.c. If the second argument is true, it will step into templates, and if it is false, it won't. Incidentally, the ICE occurs when DECL_CLONED_FUNCTION is applied to a template function, so this is not a hypothetical case. :-)
IMHO, it doesn't make sense to me to have a predicate that can potentially succeed on templates, when the macro itself will fail. However, I don't understand how cloned functions work, so I may be missing something here -- perhaps a template function is never a clone, so the predicate still returns NULL in that case? But if so, then why step into templates at all? -DeLesley On Thu, Sep 29, 2011 at 8:42 AM, Diego Novillo <dnovi...@google.com> wrote: > > On Thu, Sep 29, 2011 at 11:26, Ollie Wild <a...@google.com> wrote: > > On Thu, Sep 29, 2011 at 10:13 AM, Delesley Hutchins <deles...@google.com> > > wrote: > >> > >> Unfortunately, DECL_CLONED_FUNCTION_P is not actually a predicate that > >> allows you > >> to call DECL_CLONED_FUNCTION safely. Look at the definition of the > >> macros; despite > >> what the comments say, DECL_CLONED_FUNCTION_P may return true in cases > >> where > >> DECL_CLONED_FUNCTION will still crash. The correct fix is to fix the > >> macros, but I > >> have no understanding of what they are actually doing. :-( > >> -DeLesley > > > > Diego, can you comment? > > Really? That's surprising. I would certainly expect > DECL_CLONED_FUNCTION_P to be exactly the right predicate to guard > DECL_CLONED_FUNCTION with. That's how it's used elsewhere. > > Delesley, can you give more details on when DECL_CLONED_FUNCTION_P > fails? Changing that predicate with: > > if (DECL_CLONED_FUNCTION_P (clone) > && DECL_CLONED_FUNCTION (clone) == decl) > > should be all you need. If that's not working, then send me the test > case, cause I'll be confused :) > > > Diego.