This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Fix type safeness in C++ front-end and dynamic_cast


The problem here is that the types in a compare between a pointer
and null when generating it for a dynamic_cast.
This patch fixes that problem by calling cp_convert on the
integer_zero_cst.

OK? Bootstrapped and tested on ppc-darwin with no regressions.

Thanks,
Andrew Pinski

ChangeLog:
	* rtti.c (ifnonnull): Cast the zero comparison operand
	to the correct type.

Patch:

Attachment: t.diff.txt
Description: Text document




Testcase: // { dg-do compile } // { dg-options "-O2" } // We used to ICE in compare_values as the types for a comparison // we not the same kind of types. struct class1 { virtual ~class1 (); }; struct class2 : class1 { };

void f(class1 * oo)
{
  class2 * oj = dynamic_cast <class2 *>(oo) ;
  if (oj)
    delete oo;
}

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]