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]

Re: [PATCH] PR fortran/24005


On Thu, Sep 22, 2005 at 10:36:59PM +0200, Tobias Schl?ter wrote:
> Steve Kargl wrote:
> > --- 926,933 ----
> >   	if (p->sym == q->sym)
> >   	  continue;		/* Duplicates OK here */
> >   
> > ! 	if (p->sym->name && q->sym->name && p->sym->module && q->sym->module
> > ! 	    && strcmp (p->sym->name, q->sym->name) == 0
> >   	    && strcmp (p->sym->module, q->sym->module) == 0)
> >   	  continue;
> 
> p->sym->name and q->sym->name should never be NULL.

In my debugging, only p->sym-module was NULL.  I'll happily
remove these checks (although they can't hurt).

> Furthermore, the module name needn't be set, as interfaces can
> reference symbols in the current scope,
> IOW the correct check would be:
> 
> if (strcmp (p->sym->name, q->sym->name) == 0
>     && ((!p->sym->module && !q->sym->module)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>         || (p->sym->module && q->sym->module
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Shouldn't we need only one of these?

>             && strcmp (p->sym->module, q->sym->module) == 0)))
> 
> NB I remember that we stumbled across a very similar bug when I
> introduced the string table changes, which it turned out I had
> missed, because glibc's strcmp does "the right thing" with NULL
> arguments unlike FreeBSD's.

I don't know the C standard requirements to argue for or against
who is doing the right thing.  I do know that gfortran seg faults
without my patch and runs fine with it.

>  Alternatively,
> (if I understand C well enough) we could simply compare the string pointers
> (they're allocated by gfc_get_string) like so:
> 
> if (p->sym->name == q->sym->name && p->sym->module == q->sym->module)

I'll try the above.  IIRC the string table stuff should contain 
unique strings.

-- 
Steve


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