Skip to content

crashing code #748

@faassen

Description

@faassen

I have a piece of code that crashes as soon as a function gets called. It is dependent on the size of the data and also on how the data is passed into the code.

const WIDTH = 640
const HEIGHT = 327

type
  TField = tuple [
    a: float,
    b: float,
    c: float,
    d: float,
    e: float]
  TRow = array[0..WIDTH - 1, TField]
  TGrid = array[0..HEIGHT -1, TRow]
  TWorld = tuple [grid: TGrid]

proc display(world: TWorld) =
  for r, row in world.grid:
    for c, field in row:
      echo("init " & $(r) & " " & $(c))

var w: TWorld

w.display()

If you modify WIDTH to be one less, the code works. The crash seems to be as soon as the display proc is reached; the display proc isn't even executed. If you add another tuple field to TField the code fails even with HEIGHT 327.

If you modify display to get TGrid as a parameter directly and call display on it, it seems to work for arbitrary HEIGHTs.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions