This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: Optimising away memset() calls?
- From: Andrew Haley <aph at redhat dot com>
- To: Sandy Harris <sandyinchina at gmail dot com>, gcc-help at gcc dot gnu dot org
- Date: Fri, 10 Oct 2014 18:29:18 +0100
- Subject: Re: Optimising away memset() calls?
- Authentication-results: sourceware.org; auth=none
- References: <CACXcFm=c0kf-2M2V_D+L2PdEoD4qcqKNVmPGQkv8FRKEqw3Zmw at mail dot gmail dot com> <543660DA dot 8010706 at redhat dot com> <5436F593 dot 4020001 at gmail dot com> <5437A4C3 dot 5090009 at redhat dot com> <CACXcFmm-wx8QfpGkMOq0sbm0Fm2zd3-kHyW89YxAT53_RF=dfQ at mail dot gmail dot com>
On 10/10/2014 02:10 PM, Sandy Harris wrote:
> On Fri, Oct 10, 2014 at 5:20 AM, Andrew Haley <aph@redhat.com> wrote:
>
>>> The compiler would need to know that memset_s is special (either
>>> intrinsically or thorugh eg. function attributes). Either way, IMHO
>>> an advanced knowledge allowing to optimize it out would be a
>>> violation of K.3.7.4.1.
>>
>> It would be a perverse thing to do and goes against intent, but we
>> again fall into the problem of defining an access. ... So,
>> all we can have here is a best effort. Anyone who wants to be sure
>> that the key is wiped is going to have to do something machine-
>> dependent.
>
> I agree there may have to be some machine-dependent code, but
> it seems to me it should be in the definition of memset_s(). The
> library code (or the compiler if it provides it as a built-in) should
> deal with this so application programmers do not have to.
I don't think you read what I wrote. Or think it said something
different from what I intended.
Andrew.