In DMD 1.049, this code used to work: -- bug01a.d ---------- module bug01a; import bug01b; union any {} typedef any ANY; -- bug01b.d ----------- module bug01b; import bug01a; struct circular_definition { union { ANY subany; } } Later (not sure when, but have tested on DMD 1.059) - this code began failing with the message: bug01a.d(4): Error: typedef bug01a.ANY circular definition Now - this code fails and ICE's the compiler: bug01a.d(4): Error: typedef bug01a.ANY circular definition Segmentation fault Other things to note about the bug, swapping the typedef and union declaration in bug01a.d works -- bug02a.d ---------- module bug02a; import bug02b; typedef any ANY; union any {} However, adding another struct in the second module triggers it again -- bug02b.d ---------- module bug02b; import bug02a; struct circular_definition { union { ANY subany; } } struct triggers_bug {} And ultimately, putting the import at the bottom means it compiles successfully all the time. -- works01a.d ---------- module works01a; typedef any ANY; union any {} import works01b; Regards
According to Andrei 'typedef' will be removed from the language. Is an 'alias' there giving the same troubles?
(In reply to comment #1) > According to Andrei 'typedef' will be removed from the language. > Is an 'alias' there giving the same troubles? That it does not. Also, I thought typedef was being removed only for D2? This is sad news for me...
You are right, typedef will be removed from D1 only.
You are right, typedef will be removed from D2 only.
Both of the unions in the test case can be replaced with structs without changing the behaviour. The union inside circular_definition must be anonymous. If it is given a name, compilation succeeds. Also, if union any {} is changed into: alias int any; then it segfaults on 2.038. So the fact that it started segfaulting on the union case is probably not important.
Bug 3976 is probably a duplicate of this one.
*** Issue 3976 has been marked as a duplicate of this issue. ***
Caused by svn 318, which was fixing bug 282 "Bizarre circular import nested name invisibility issue". Regression bug 3682 was introduced at the same time.
Created attachment 926 [details] Fix issue4543 segv Bump. Patch to prevent ICE from occurring, but doesn't stop the forward reference error.
And have no testsuite regressions on Linux as a result of the patch.
Created attachment 934 [details] issue4543 Attached fix for this issue. Formal testcase: === a4543.d === import b4543; class bclass {}; typedef bclass Tclass; struct bstruct {} typedef bstruct Tstruct; === b4543.d === import a4543; class A { struct { Tclass a; Tstruct b; } union { Tclass c; Tstruct d; } } struct B { struct { Tclass a; Tstruct b; } union { Tclass c; Tstruct d; } }
>--- 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
https://github.com/D-Programming-Language/dmd/commit/c9860015025ce73088d8765e83b0b7bc106237e9 https://github.com/D-Programming-Language/dmd/commit/0c68e90db36a2549ccf9d946af803e726b573e07 https://github.com/D-Programming-Language/dmd/commit/930e029c037c48e3444f0ad657719d9f5b5d23c6
dlang/dmd pull request #10890 "Remove obsolete test for issue 4543" was merged into master: - e5411c1cbeee57c5875fb6a1d6eb9782d3836cc4 by Geod24: Remove obsolete test for issue 4543 Typedef is long gone and the test was typedef-specific. https://github.com/dlang/dmd/pull/10890
AltStyle によって変換されたページ (->オリジナル) / アドレス: モード: デフォルト 音声ブラウザ ルビ付き 配色反転 文字拡大 モバイル