This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] Fix segfault with -fdump-tree-all-all
On Wed, Mar 19, 2008 at 04:44:52PM +0100, Richard Guenther wrote:
> On Wed, Mar 19, 2008 at 4:29 PM, Martin Jambor <mjambor@suse.cz> wrote:
> > Hi,
> >
> > I made myself a simple c++ test case (preprocessed source attached)
> > and found out that the trunk gcc was segfaulting at it when run with
> > -fdump-tree-all-all. The segfault can be fixed by the following patch
> > which I have not regression tested nor bootstrapped. I hope it is so
> > simple that someone will test and commit it alongside something else.
> > Finally, the author of the modified code might want to handle the
> > problem differently....
> >
> > Thanks for attention,
>
> I also hit the case of NULL ddr somewhen, so checking for that as well
> would be nice.
OK, the following is equally untested (though compiles and does not
segfault) but not much more complex.
Changelog:
2008-03-19 Martin Jambor <mjambor@suse.cz>
* tree-data-ref.c (dump_data_dependence_relation): Avoid data
reference dumps if ddr is NULL or dependence is unknown.
Patch:
Index: gcc/tree-data-ref.c
===================================================================
--- gcc/tree-data-ref.c (revision 133342)
+++ gcc/tree-data-ref.c (working copy)
@@ -358,17 +358,20 @@ dump_data_dependence_relation (FILE *out
{
struct data_reference *dra, *drb;
- dra = DDR_A (ddr);
- drb = DDR_B (ddr);
fprintf (outf, "(Data Dep: \n");
+ if (!ddr || DDR_ARE_DEPENDENT (ddr) == chrec_dont_know)
+ {
+ fprintf (outf, " (don't know)\n)\n");
+ return;
+ }
+
+ dra = DDR_A (ddr);
+ drb = DDR_B (ddr);
dump_data_reference (outf, dra);
dump_data_reference (outf, drb);
- if (DDR_ARE_DEPENDENT (ddr) == chrec_dont_know)
- fprintf (outf, " (don't know)\n");
-
- else if (DDR_ARE_DEPENDENT (ddr) == chrec_known)
+ if (DDR_ARE_DEPENDENT (ddr) == chrec_known)
fprintf (outf, " (no dependence)\n");
else if (DDR_ARE_DEPENDENT (ddr) == NULL_TREE)