On 26.11.2025 17.23, Philipp Klaus Krause <[email protected]> wrote:
Formally, array parameters (without static) are no different from pointer parameters. However, they have often been used to express the intent of the parameter being an array of a certain size.

Do you have any preferences on what SDCC should do? Currently SDCC does not warn (neither does clang), while GCC sometimes does:


// Tested via gcc/clang -Wall -pedantic -Warray-parameter -Warray-bounds test.c

void f(char a[4])
{
     a[4] = 7; // neither gcc nor clang warn
}

void g(void)
{
     char a[3];
     f(a); // gcc warns, clang doesn't.
     f(0); // neither gcc nor clang warn
}


Would you like to see warnings in SDCC for any of these?

Philipp



_______________________________________________
Sdcc-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/sdcc-user

Anything the compiler can detect at compiletime should be either a warning or 
an error.
Coming from Ada, it seems weird that the compiler does not flag everything it 
can detect at compile time. It saves so much debugging.

Erlo


_______________________________________________
Sdcc-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/sdcc-user

Reply via email to