You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Sorry to give c4go a hard time. I really care about the issues that are unexplored in c4go. Maybe I will explore this tool.
Source C Code:
#include<stdio.h>intmain() {
intarray2D[3][3];
int (*pArray2D)[3] =array2D;
inti, j;
for ( i=0; i<3; i++) {
for (j=0; j<3; j++) {
*(*(pArray2D+i) +j) =5;
}
}
printf("Test: %.d\n", pArray2D[0][0]);
return0;
}
Output Go code:
//// Package - transpiled by c4go//// If you have found any issues, please raise an issue at:// https://github.com/Konstantin8105/c4go///package main
import"github.com/Konstantin8105/c4go/noarch"// main - transpiled function from /mnt/bigdata/YEASEEN/FuzzTranspilers-main/fuzzers/TFuzz/pre_post_works/c4go_transpile/runner.c:2funcmain() {
vararray2D [][]int32=make([][]int32, 3)
varpArray2D [][]int32=array2Dvariint32varjint32fori=0; i<3; i++ {
forj=0; j<3; j++ {
(pArray2D[0+i])[0+j] =5
}
}
noarch.Printf([]byte("Test: %.d\n\x00"), pArray2D[0][0])
return
}
Go build Successful
Runtime Error
panic: runtime error: index out of range [0] with length 0
goroutine 1 [running]:
main.main()
/mnt/bigdata/YEASEEN/FuzzTranspilers-main/fuzzers/TFuzz/pre_post_works/c4go_transpile/runner.go:20 +0xfe
Root cause:
2D array initialization. The inner slices are still 'nil'
What modification worked:
//// Package - transpiled by c4go//// If you have found any issues, please raise an issue at:// https://github.com/Konstantin8105/c4go///package main
import"github.com/Konstantin8105/c4go/noarch"// main - transpiled function from /mnt/bigdata/YEASEEN/FuzzTranspilers-main/fuzzers/TFuzz/pre_post_works/c4go_transpile/runner.c:2funcmain() {
// Create a 2x2 array with initialized slicesvararray2D [][]int32=make([][]int32, 3)
fori:=rangearray2D {
array2D[i] =make([]int32, 3)
}
// Assign the pointer to the arrayvarpArray2D [][]int32=array2Dvariint32varjint32fori=0; i<3; i++ {
forj=0; j<3; j++ {
(pArray2D[0+i])[0+j] =5
}
}
noarch.Printf([]byte("Test: %.d\n\x00"), pArray2D[0][0])
return
}
The text was updated successfully, but these errors were encountered:
Yeaseen
changed the title
Failure at Pointer Arithmetic with 2D Arrays in C
Failure at 2D Array Initialization
Aug 31, 2024
Sorry to give c4go a hard time. I really care about the issues that are unexplored in c4go. Maybe I will explore this tool.
Source C Code:
Output Go code:
Go build Successful
Runtime Error
Root cause:
2D array initialization. The inner slices are still 'nil'
What modification worked:
The text was updated successfully, but these errors were encountered: