Re: Cleanup for cryptographic algorithms vs. compiler optimizations

From: Dag-Erling Smørgrav <des_at_des.no>
Date: Sat, 12 Jun 2010 19:35:26 +0200
Bernd Walter <ticso_at_cicely7.cicely.de> writes:
> I'm not sure when removing a memset is allowed.

Always, if the compiler can determine that the data will not be used
later.

In more general terms, the compiler is allowed to make any changes it
likes to the program as long as the end result behaves exactly like it
would if it hadn't been changed.  This is called the "as if" rule.  For
instance, if you call printf() or fprintf() with a format string that
does not contain any conversion specifiers, gcc will call gets() or
fgets() instead.

> Maybe passing volatile pointers might be enough.

You can't pass a volatile pointer to memset.

DES
-- 
Dag-Erling Smørgrav - des_at_des.no
Received on Sat Jun 12 2010 - 15:37:37 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:40:04 UTC