[Issue 4543] Regression(1.054, 2.038) typedef circular definition and segfault

d-bugmail at puremagic.com d-bugmail at puremagic.com
Thu Mar 24 12:44:24 PDT 2011


http://d.puremagic.com/issues/show_bug.cgi?id=4543



--- Comment #12 from Iain Buclaw <ibuclaw at ubuntu.com> 2011-03-24 12:41:02 PDT ---
>--- a/src/class.c
>+++ b/src/class.c
>@@ -870,14 +870,14 @@ Dsymbol *ClassDeclaration::search(Loc loc, Identifier *ident, int flags)
>     Dsymbol *s;
>     //printf("%s.ClassDeclaration::search('%s')\n", toChars(), ident->toChars());
> 
>-    if (scope)
>+    if (scope && !symtab)
>     {   Scope *sc = scope;
>         sc->mustsemantic++;
>         semantic(sc);
>         sc->mustsemantic--;
>     }
> 
>-    if (!members || !symtab || scope)
>+    if (!members || !symtab)
>     {
>         error("is forward referenced when looking for '%s'", ident->toChars());
>         //*(char*)0=0;

Here (and in StructDeclaration), if (!symtab) looks to be a sure sign that the
semantic pass hasn't been started yet. Also, if (!members), the semantic won't
run anyway, so you are in trouble even if you do call the semantic in the
search method.

Extending the condition instead to (scope && !symtab) is enough to fix/bypass
the forward reference errors for StructDeclaration's while not hurting bug282
which depends on the semantic being called. As for ClassDeclaration's,
something extra is needed (as you can see above), I'm not sure of the
importance of (scope) *needing* to be NULL here, but removing the check doesn't
seem to harm (at least) the testsuite.

Regards

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list