14.10.2018, 10:17
Is this a normal behavior of const-correctness? The compiler complains (as it should) about 1D array but not for 2D, 3D or 4D arrays
No warnings. It modifies the value even though it is meant to be a constant array.
pawn Код:
#include <a_samp>
main()
{
new arr[10];
func(arr);
printf("value: %d", arr[0]);
}
func(const arr[])
{
arr[0] = 1; // error 022: must be lvalue (non-constant)
}
pawn Код:
#include <a_samp>
main()
{
new arr[10][10];
func(arr);
printf("value: %d", arr[0][0]); // prints "value: 1"
}
func(const arr[][])
{
arr[0][0] = 1;
}