This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] PR fortran/24005
- From: Tobias Schlüter <tobias dot schlueter at physik dot uni-muenchen dot de>
- To: Steve Kargl <sgk at troutmask dot apl dot washington dot edu>
- Cc: fortran at gcc dot gnu dot org, gcc-patches at gcc dot gnu dot org
- Date: Thu, 22 Sep 2005 22:36:59 +0200
- Subject: Re: [PATCH] PR fortran/24005
- References: <20050922194925.GA59701@troutmask.apl.washington.edu>
Steve Kargl wrote:
> The problem, again discussed in the PR, is that gfortran was
> passing a NULL pointer to strcmp.
>
> OK for mainline?
This is not yet ok ...
> --- 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. 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
&& 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. 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)
- Tobi