bmx-ng / bcc

A next-generation bcc parser for BlitzMax
zlib License
33 stars 12 forks source link

Segfault when using an array entry as looping variable #578

Open GWRon opened 2 years ago

GWRon commented 2 years ago

"PrincessAlexa_Hehehe" brought up an issue on our discord server: a segfault in some hmm.. uncommon use of arrays. I truncated the issue down to this:

SuperStrict
Framework Brl.StandardIO

Global intArray:Int[1]
For intArray[0] = 0 To 10
    Print intArray[0]
Next

It (bcc) segfaults when using an array element as loop variable in for loops.

woollybah commented 2 years ago

It probably shouldn't compile.

GWRon commented 2 years ago

Hmm now I have to ask: why shouldnt it compile at all - isnt it allowed to use an integer variable (which the array entry is) as loop element?

HurryStarfish commented 2 years ago

I agree with GWRon - this should definitely compile. An array element is an lvalue - I don't see why it shouldn't be usable as a loop counter. Plus, it already works in legacy BlitzMax, so this is a compatibility-breaking bug. Going one step further actually, this should be allowed with user-defined types that have a matching Operator [] and Operator []= as well.

GWRon commented 1 year ago

Just want to "revalidate" it. Still fails to compile.

BCC segfaults in expr.bmx's method Semant:TExpr()' becausetyisnull`.

image