digitalmars.D.learn - Dynamic arrays / ~= giving an exception...
- =?iso-8859-1?Q?Robert_M._M=FCnch?= (21/21) Jul 01 2018 I'm a bit puzzled because I think this is pretty straight forward but
 - =?iso-8859-1?Q?Robert_M._M=FCnch?= (10/32) Jul 01 2018 One more thing, myPtr* is a pointer to a C struct. So I have:
 - Cym13 (2/19) Jul 01 2018 Could you maybe provide a compilable example?
 - =?iso-8859-1?Q?Robert_M._M=FCnch?= (12/37) Jul 01 2018 I would like but I can't condense it down to a useable case. What I
 - Steven Schveighoffer (11/34) Jul 02 2018 It should work. We need more context to try and help figure it out. Even...
 - Jonathan M Davis (6/8) Jul 02 2018 If the program size is too large to show a good example, then I'd sugges...
 
I'm a bit puzzled because I think this is pretty straight forward but 
doesn't work...
struct mystruct {
	myPtr* root;
	opApply(...){
		myPtr*[] childs;
		
		childs ~= root;
		...
	}
}
foreach(node; mystruct(myRoot)){
	...
}
It compiles but the line with ~= gives the nice "bing" under Windows 
and the application hangs...
What doesn't this work?
-- 
Robert M. Münch
http://www.saphirion.com
smarter | better | faster
 Jul 01 2018
On 2018-07-01 20:55:16 +0000, Robert M. Münch said:
 I'm a bit puzzled because I think this is pretty straight forward but 
 doesn't work...
 
 struct mystruct {
 	myPtr* root;
 
 	opApply(...){
 		myPtr*[] childs;
 		
 		childs ~= root;
 		...
 	}
 }
 
 foreach(node; mystruct(myRoot)){
 	...
 }
 
 It compiles but the line with ~= gives the nice "bing" under Windows 
 and the application hangs...
 
 What doesn't this work?
One more thing, myPtr* is a pointer to a C struct. So I have:
extern(C) {
	struct myPtr;
	alias myPtrRef = myPtr*;
}
-- 
Robert M. Münch
http://www.saphirion.com
smarter | better | faster
 Jul 01 2018
On Sunday, 1 July 2018 at 20:55:16 UTC, Robert M. Münch wrote:
 I'm a bit puzzled because I think this is pretty straight 
 forward but doesn't work...
 struct mystruct {
 	myPtr* root;
 	opApply(...){
 		myPtr*[] childs;
 		
 		childs ~= root;
 		...
 	}
 }
 foreach(node; mystruct(myRoot)){
 	...
 }
 It compiles but the line with ~= gives the nice "bing" under 
 Windows and the application hangs...
 What doesn't this work?
Could you maybe provide a compilable example?
 Jul 01 2018
On 2018-07-01 21:05:43 +0000, Cym13 said:On Sunday, 1 July 2018 at 20:55:16 UTC, Robert M. Münch wrote:I would like but I can't condense it down to a useable case. What I found out is, if I use: auto childs_app = appender(&childs); childs_app ~= root; things work. Does this give a hint why the plain straight version doesn't work? Maybe missing copy semantics or so? Just wild guessing here... -- Robert M. Münch http://www.saphirion.com smarter | better | fasterI'm a bit puzzled because I think this is pretty straight forward but doesn't work... struct mystruct { myPtr* root; opApply(...){ myPtr*[] childs; childs ~= root; ... } } foreach(node; mystruct(myRoot)){ ... } It compiles but the line with ~= gives the nice "bing" under Windows and the application hangs... What doesn't this work?Could you maybe provide a compilable example?
 Jul 01 2018
On 7/1/18 4:55 PM, Robert M. Münch wrote:
 I'm a bit puzzled because I think this is pretty straight forward but 
 doesn't work...
 
 struct mystruct {
      myPtr* root;
 
      opApply(...){
          myPtr*[] childs;
 
          childs ~= root;
          ...
      }
 }
 
 foreach(node; mystruct(myRoot)){
      ...
 }
 
 It compiles but the line with ~= gives the nice "bing" under Windows and 
 the application hangs...
 
 What doesn't this work?
 
It should work. We need more context to try and help figure it out. Even 
if you can't post the entire program, maybe more context from mystruct.
In general:
T*[] arr;
arr ~= someTPtr;
should ALWAYS work. There is absolutely no postblits or dangling 
pointers happening at THIS point, and you are allocating an array to 
hold a pointer.
I suspect that your diagnosis of where the problem is happening is faulty.
-Steve
 Jul 02 2018
On Monday, July 02, 2018 14:46:28 Steven Schveighoffer via Digitalmars-d- learn wrote:It should work. We need more context to try and help figure it out. Even if you can't post the entire program, maybe more context from mystruct.If the program size is too large to show a good example, then I'd suggest using dustmite to reduce it. That can sometimes take a while, but it should then give us something where we have a chance of diagnosing the problem. - Jonathan M Davis
 Jul 02 2018








 
 
 
 =?iso-8859-1?Q?Robert_M._M=FCnch?= <robert.muench saphirion.com> 