www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - DMD Access Violation

reply Jonathan Marler <johnnymarler gmail.com> writes:
My dmd compiler gets an Access Violation when compiling this code:

     public template TemplateWrapper(T)
     {
         alias ToAlias = T;
     }
     public class Bar : Foo
     {
         TemplateWrapper!(Bar) something;
     }
     public class Foo
     {
         static class StaticClass : Bar { }
     }

If I move Foo to appear before Bar, the AccessViolation goes away:

     public template TemplateWrapper(T)
     {
         alias ToAlias = T;
     }
     public class Foo
     {
         static class StaticClass : Bar { }
     }
     public class Bar : Foo
     {
         TemplateWrapper!(Bar) something;
     }

Also, if I remove the TemplateWrapper, the AccessViolation goes 
away:

     public class Bar : Foo
     {
         Bar something;
     }
     public class Foo
     {
         static class StaticClass : Bar { }
     }

Does anyone else get an access violation in the first case? Is 
this a known bug?
Sep 26 2016
next sibling parent reply Stefan Koch <uplink.coder googlemail.com> writes:
On Monday, 26 September 2016 at 18:07:44 UTC, Jonathan Marler 
wrote:
 My dmd compiler gets an Access Violation when compiling this 
 code:

     public template TemplateWrapper(T)
     {
         alias ToAlias = T;
     }
     public class Bar : Foo
     {
         TemplateWrapper!(Bar) something;
     }
     public class Foo
     {
         static class StaticClass : Bar { }
     }

 If I move Foo to appear before Bar, the AccessViolation goes 
 away:

     public template TemplateWrapper(T)
     {
         alias ToAlias = T;
     }
     public class Foo
     {
         static class StaticClass : Bar { }
     }
     public class Bar : Foo
     {
         TemplateWrapper!(Bar) something;
     }

 Also, if I remove the TemplateWrapper, the AccessViolation goes 
 away:

     public class Bar : Foo
     {
         Bar something;
     }
     public class Foo
     {
         static class StaticClass : Bar { }
     }

 Does anyone else get an access violation in the first case? Is 
 this a known bug?
Cyclic dependency. File a dmd bug please.
Sep 26 2016
parent Jonathan Marler <johnnymarler gmail.com> writes:
On Monday, 26 September 2016 at 18:23:33 UTC, Stefan Koch wrote:
 On Monday, 26 September 2016 at 18:07:44 UTC, Jonathan Marler
 Does anyone else get an access violation in the first case? Is 
 this a known bug?
Cyclic dependency. File a dmd bug please.
Well I'm not sure if it's a bug with the main compiler or my own build. The Access Violation doesn't seem to happen on one of my rigs, but it does with the other, and that one is using a custom build of DMD...just wanted to see if anyone else's DMD also has the bug.
Sep 26 2016
prev sibling parent reply ag0aep6g <anonymous example.com> writes:
On 09/26/2016 08:07 PM, Jonathan Marler wrote:
 My dmd compiler gets an Access Violation when compiling this code:

     public template TemplateWrapper(T)
     {
         alias ToAlias = T;
Should probably be `alias TemplateWrapper = T;`.
     }
     public class Bar : Foo
     {
         TemplateWrapper!(Bar) something;
     }
     public class Foo
     {
         static class StaticClass : Bar { }
     }
With the change above, dmd 2.071.2 crashes with an assertion failure: toobj.c:352: virtual void toObjFile(Dsymbol*, bool)::ToObjFile::visit(ClassDeclaration*): Assertion `cd->structsize >= 8 || (cd->cpp && cd->structsize >= 4)' failed. Current master dmd (04e6a6e) doesn't crash. Maybe the bug has already been fixed. Reminds me of this issue: https://issues.dlang.org/show_bug.cgi?id=16273 Similar setup, but opposite results: crashes with master and works with 2.071.
Sep 26 2016
parent reply Jonathan Marler <johnnymarler gmail.com> writes:
On Monday, 26 September 2016 at 18:49:58 UTC, ag0aep6g wrote:
 On 09/26/2016 08:07 PM, Jonathan Marler wrote:
 My dmd compiler gets an Access Violation when compiling this 
 code:

     public template TemplateWrapper(T)
     {
         alias ToAlias = T;
Should probably be `alias TemplateWrapper = T;`.
     }
     public class Bar : Foo
     {
         TemplateWrapper!(Bar) something;
     }
     public class Foo
     {
         static class StaticClass : Bar { }
     }
With the change above, dmd 2.071.2 crashes with an assertion failure: toobj.c:352: virtual void toObjFile(Dsymbol*, bool)::ToObjFile::visit(ClassDeclaration*): Assertion `cd->structsize >= 8 || (cd->cpp && cd->structsize >= 4)' failed. Current master dmd (04e6a6e) doesn't crash. Maybe the bug has already been fixed. Reminds me of this issue: https://issues.dlang.org/show_bug.cgi?id=16273 Similar setup, but opposite results: crashes with master and works with 2.071.
Thanks for the info. I'll have to update my compiler to master, or go back to 2.071.
Sep 26 2016
parent ag0aep6g <anonymous example.com> writes:
On 09/26/2016 08:53 PM, Jonathan Marler wrote:
 Thanks for the info.  I'll have to update my compiler to master, or go
 back to 2.071.
You'd have to go back to a 2.070 version. The 2.071 versions all crash on your code.
Sep 26 2016