I encountered a bug so oddly specific that it is funny to me.
Thus I share it here. If you can reproduce it, that would be interesting to know.
issue-on-github
But here is it once more:
package main
import "core:fmt"
import "core:math/linalg"
fe :: proc() {
G := matrix[4, 4]f64{}
r := [4]f64{}
alpha: f64 = 0.85
for i in 0 ..< 1 {
//Segmentation fault
r = alpha * G * r
}
fmt.println("fe ok")
}
f1 :: proc() {
// using a 3x3 mat works
G := matrix[3, 3]f64{}
r := [3]f64{}
alpha: f64 = 0.85
for i in 0 ..< 1 {
r = alpha * G * r
}
fmt.println("f1 ok")
}
f2 :: proc() {
G := matrix[4, 4]f64{}
r := [4]f64{}
alpha: f64 = 0.85
// not using a loop works
r = alpha * G * r
fmt.println("f2 ok")
}
f3 :: proc() {
G := matrix[4, 4]f64{}
r := [4]f64{}
alpha: f64 = 0.85
for i in 0 ..< 1 {
//changing order of evaluation works
r = alpha * (G * r)
}
fmt.println("f3 ok")
}
f4 :: proc() {
G := matrix[4, 4]f64{}
r := [4]f64{}
alpha: f64 = 0.85
//using another variable instad of assigning to r works
r2: [4]f64
for i in 0 ..< 1 {
r2 = alpha * G * r
}
fmt.println("f4 ok")
}
f5 :: proc() {
G := matrix[4, 4]f64{}
r := [4]f64{}
for i in 0 ..< 1 {
// using a literal works
r = 0.85 * G * r
}
fmt.println("f5 ok")
}
main :: proc() {
f1()
f2()
f3()
f4()
f5()
fe()
}
OUTPUT:
f1 ok
f2 ok
f3 ok
f4 ok
f5 ok
Segmentation fault (core dumped)