Scoped local variables
Jason House
jason.james.house at gmail.com
Fri Dec 7 14:03:19 PST 2007
Frank Benoit Wrote:
> It is a bug. I can reproduce it on linux/dmd.
> Would you mind to file a bug report?
Before I'd do, I'd like to know if the following things make a difference:
1. Tango vs. Phobos
2. Latest D 1.x vs. latest D 2.x
>
>
> Jason House schrieb:
> > Denton Cockburn Wrote:
> >
> >> On Fri, 07 Dec 2007 09:52:07 -0500, Jason House wrote:
> >>
> >>> I'm having my code crash when I add in scope variables. While it works
> >>> in some cases, it doesn't in others. I've whittled down my current
> >>> problem to code that looks like:
> >>>
> >>> unittest{
> >>> scope T t = new T();
> >>> }
> >>>
> >>> "T" has a bunch of arrays that it allocates and fills when it's
> >>> constructed. I'm currently confused how this code would cause a crash.
> >>> Any insights would be much appreciated.
> >> Need more information.
> >> What's the message given when it crashes?
> >
> > It's a windows error:
> > housebot-0.7 has encountered a problem and needs to close. We are sorry for the inconvenience. If you were in the middle of something, the information you were working on might be lost.
> >
> >
> >> Is the cause of the crash the fact that it's scoped?
> >
> > As best as I can tell.
> >
> >> Have you tried without scope?
> >
> > Yes, it works flawlessly without the scope.
> >
> >> Are you sure it's not in the constructor of T?
> >
> > I am now. I stripped it down to an empty constructor and removed all member variables.
> >
> > Since posting, I've reduced this down to a simple example. This example sometimes crashes dmd itself instead of producing a crashing executable. I'm using dmd 1.018 with Tango 0.99. Now that I know it's dmd and not me, I may try upgrading the version of dmd that I use.
> >
> > version=crash;
> > //version=work1;
> > //version=work2;
> > //version=work3;
> >
> > interface I{
> > }
> >
> > class C : public I{
> > }
> >
> > unittest{
> > version(crash) scope I def = new C;
> > version(work1) scope C def = new C;
> > version(work2) I def = new C;
> > version(work3) C def = new C;
> > }
> >
> > int main(){
> > return 0;
> > }
More information about the Digitalmars-d-learn
mailing list