void
encrypt(void *data, size_t len, char *password)
{
char key[32];
turn_password_into_key(password, key, sizeof key);
aes_make_encrypted(data, len, key);
memset(key, 0, sizeof key); /* optimized away */
}
The compiler knows what memset does. It also knows that stack variables have no use after the function returns. Therefore, the compiler knows there is no reason to write zeroes to this memory, because the program will never read those zeroes. Hence, the compiler will delete the call to memset.