Thread overview | |||||||
---|---|---|---|---|---|---|---|
|
August 22, 2003 Access violation | ||||
---|---|---|---|---|
| ||||
I think this is another nested function issue. When the array is accessed in the if statement the program bombs. struct Foo { int[] arr; } void Func(Foo bar) { void InnerFunc(int x, int y) { int a = bar.arr[y]; // Ok if(bar.arr[y]) // Access violation { } } InnerFunc(5,5); } int main(char[][] argv) { Foo bar; bar.arr.length = 10; Func(bar); return 0; } |
August 23, 2003 Re: Access violation | ||||
---|---|---|---|---|
| ||||
Posted in reply to Patrick Down | Try: Foo bar = new Foo(); "Patrick Down" <pat@codemoon.com> wrote in message news:Xns93DEDC71D4F74patcodemooncom@63.105.9.61... > > I think this is another nested function > issue. When the array is accessed in the if > statement the program bombs. > > > struct Foo > { > int[] arr; > } > > void Func(Foo bar) > { > void InnerFunc(int x, int y) > { > int a = bar.arr[y]; // Ok > > if(bar.arr[y]) // Access violation > { > } > } > > InnerFunc(5,5); > } > > > int main(char[][] argv) > { > Foo bar; > > bar.arr.length = 10; > > Func(bar); > > return 0; > } |
August 23, 2003 Re: Access violation | ||||
---|---|---|---|---|
| ||||
Posted in reply to Walter | "Walter" <walter@digitalmars.com> wrote in news:bi8is8$4h8$1 @digitaldaemon.com: > Try: > Foo bar = new Foo(); Foo is a struct why does it need a new? > > "Patrick Down" <pat@codemoon.com> wrote in message news:Xns93DEDC71D4F74patcodemooncom@63.105.9.61... >> >> I think this is another nested function >> issue. When the array is accessed in the if >> statement the program bombs. >> >> >> struct Foo >> { >> int[] arr; >> } >> >> void Func(Foo bar) >> { >> void InnerFunc(int x, int y) >> { >> int a = bar.arr[y]; // Ok >> >> if(bar.arr[y]) // Access violation >> { >> } >> } >> >> InnerFunc(5,5); >> } >> >> >> int main(char[][] argv) >> { >> Foo bar; >> >> bar.arr.length = 10; >> >> Func(bar); >> >> return 0; >> } > > |
August 24, 2003 Re: Access violation | ||||
---|---|---|---|---|
| ||||
Posted in reply to Patrick Down | Sorry, you're right. "Patrick Down" <pat@codemoon.com> wrote in message news:Xns93E0A875E661Epatcodemooncom@63.105.9.61... > "Walter" <walter@digitalmars.com> wrote in news:bi8is8$4h8$1 @digitaldaemon.com: > > > Try: > > Foo bar = new Foo(); > > Foo is a struct why does it need a new? > > > > > "Patrick Down" <pat@codemoon.com> wrote in message news:Xns93DEDC71D4F74patcodemooncom@63.105.9.61... > >> > >> I think this is another nested function > >> issue. When the array is accessed in the if > >> statement the program bombs. > >> > >> > >> struct Foo > >> { > >> int[] arr; > >> } > >> > >> void Func(Foo bar) > >> { > >> void InnerFunc(int x, int y) > >> { > >> int a = bar.arr[y]; // Ok > >> > >> if(bar.arr[y]) // Access violation > >> { > >> } > >> } > >> > >> InnerFunc(5,5); > >> } > >> > >> > >> int main(char[][] argv) > >> { > >> Foo bar; > >> > >> bar.arr.length = 10; > >> > >> Func(bar); > >> > >> return 0; > >> } > > > > > |
August 25, 2003 Re: Access violation | ||||
---|---|---|---|---|
| ||||
Posted in reply to Patrick Down | You're right, it's a nasty bug. I have it fixed now, fix will go out in 0.71. Thanks, -Walter |
Copyright © 1999-2021 by the D Language Foundation