dgd icon indicating copy to clipboard operation
dgd copied to clipboard

Crashed driver while testing label and goto.

Open knubo opened this issue 1 year ago • 3 comments

I wrote (more or less this) in a function:

void crash() {

oups:

/* Some code */

goto oups; }

The driver crashed while trying to compile this. I was looking into do a break to label from a double nested for loop, but I could not forward reference my label so I just for compile time tested to put it before the goto statement.

This was on DGD 1.7.3

knubo avatar Sep 15 '24 11:09 knubo

I can't reproduce a crash with this code.

By the way, I don't consider goto to oficially be part of LPC -- I added it to as a kind of underground feature to simplify machine-producing LPC code. As such, it does have some similarly-undocumented limitations.

dworkin avatar Sep 15 '24 14:09 dworkin

I think this is close to the code I tried to compile:

object query_tree_near(object player) {
  int *loc;
  object tree;
  int col,row;
  int x,y, found;
  
  loc = locations[player];

 jumphere:
  
  for(col=-1;col < 1 && !found; col++) {
    for(row=-1; row < 1 && !found; row++) {

      x = loc[0] + col;
      y = loc[1] + row;
      
      if(content[y*(content_size_x+1)+x] == '*') {
	found = 1;
	
	goto jumphere;
	break;
      }
    }
  }

 jumphere:
  if(!found) {
    return 0;
  }
  
  tree = clone_object("/d/Limitless/obj/tmp_tree");
  tree->set_chop_location(copy(locations[player]));
  
  
  return tree;
}

I probably tried to add and remove the labels and compile it a couple of times.

knubo avatar Sep 15 '24 14:09 knubo

Alas, that still doesn't crash.

dworkin avatar Sep 15 '24 15:09 dworkin