Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
bgColor#FFcccc
const int vals[] = {3, 4, 5};
memset(vals, 0, sizeof(vals));

Since 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 implicit cast.

Compliant Solution

If the intention is to allow the array values to be modified, do not declare the array as const.

...