...
| Code Block | ||
|---|---|---|
| ||
const int vals[] = {3, 4, 5};
memset(vals, 0, sizeof(vals));
|
Since Because the memset() function takes a (non-const) pointer to void, the compiler must implicitly cast away const.
Implementation Details
The gcc compiler will issue a warning on this code, due to the for cases such as this where an implicit cast is performed.
Compliant Solution
If the intention is to allow the array values to be modified, do not declare the array as const.
...