Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 12 Jun 2010 19:35:26 +0200
From:      =?utf-8?Q?Dag-Erling_Sm=C3=B8rgrav?= <des@des.no>
To:        ticso@cicely.de
Cc:        current@freebsd.org
Subject:   Re: Cleanup for cryptographic algorithms vs. compiler optimizations
Message-ID:  <864oh86tnl.fsf@ds4.des.no>
In-Reply-To: <20100612163208.GS87112@cicely7.cicely.de> (Bernd Walter's message of "Sat, 12 Jun 2010 18:32:08 %2B0200")
References:  <20100611162118.GR39829@acme.spoerlein.net> <867hm5tl6u.fsf@ds4.des.no> <20100612153526.GA3632@acme.spoerlein.net> <20100612163208.GS87112@cicely7.cicely.de>

next in thread | previous in thread | raw e-mail | index | archive | help
Bernd Walter <ticso@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
--=20
Dag-Erling Sm=C3=B8rgrav - des@des.no



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?864oh86tnl.fsf>