Skip to content

Commit 2342df0

Browse files
committed
fix(tests): explicitly take address of first element for pointer initialization
Signed-off-by: vibhatsu <maulikbarot2915@gmail.com>
1 parent 4e1783c commit 2342df0

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

tests/testcases/valid/expressions/07_pointer_array_access.ciel

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ int main() {
99
// Pointer to array
1010
int arr[10];
1111
int* ptr;
12-
ptr = arr;
12+
ptr = &arr[0]; // Explicitly take address of first element instead of relying on array decay
1313

1414
ptr[0] = 5;
1515
ptr[1] = 10;
@@ -64,7 +64,7 @@ int main() {
6464
// Pointer to struct array
6565
struct Point point_arr[5];
6666
struct Point* pstruct;
67-
pstruct = point_arr;
67+
pstruct = &point_arr[0]; // Explicitly take address of first element instead of relying on array decay
6868

6969
pstruct[0].x = 10;
7070
pstruct[0].y = 20;

0 commit comments

Comments
 (0)