Thread overview | |||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
December 07, 2007 Scoped local variables | ||||
---|---|---|---|---|
| ||||
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. |
December 07, 2007 Re: Scoped local variables | ||||
---|---|---|---|---|
| ||||
Posted in reply to Jason House | 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?
Is the cause of the crash the fact that it's scoped? Have you tried
without scope? Are you sure it's not in the constructor of T?
|
December 07, 2007 Re: Scoped local variables | ||||
---|---|---|---|---|
| ||||
Posted in reply to Denton Cockburn | 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; } |
December 07, 2007 Re: Scoped local variables | ||||
---|---|---|---|---|
| ||||
Posted in reply to Jason House | It is a bug. I can reproduce it on linux/dmd.
Would you mind to file a bug report?
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;
> }
|
December 07, 2007 Re: Scoped local variables | ||||
---|---|---|---|---|
| ||||
Posted in reply to Jason House Attachments: | Jason House wrote: > 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; > } No problem here with gdc 0.24, phobos and 64-bits linux. Jerome - -- +------------------------- Jerome M. BERGER ---------------------+ | mailto:jeberger@free.fr | ICQ: 238062172 | | http://jeberger.free.fr/ | Jabber: jeberger@jabber.fr | +---------------------------------+------------------------------+ |
December 07, 2007 Re: Scoped local variables | ||||
---|---|---|---|---|
| ||||
Posted in reply to Frank Benoit | 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; > > } |
December 07, 2007 Re: Scoped local variables | ||||
---|---|---|---|---|
| ||||
Posted in reply to Jason House | Jason House schrieb:
> 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
>
I did it on linux, dmd 1.023, tango
|
December 07, 2007 Re: Scoped local variables | ||||
---|---|---|---|---|
| ||||
Posted in reply to Jason House | Jason House:
> 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
On DMD v1.024 with Phobos it seems to work to me.
Bye,
bearophile
|
December 08, 2007 Re: Scoped local variables | ||||
---|---|---|---|---|
| ||||
Posted in reply to Jason House | On Fri, 07 Dec 2007 17:03:19 -0500, Jason House wrote:
> 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;
>> > }
1.023 on linux using phobos, it works fine.
Could it be a tango runtime issue?
|
December 08, 2007 Re: Scoped local variables | ||||
---|---|---|---|---|
| ||||
Posted in reply to Jérôme M. Berger | > Jason House wrote:
>> 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;
>> }
Works fine on linux with gdc 0.24 and tango.
|
Copyright © 1999-2021 by the D Language Foundation