This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Optimising away memset() calls?


On 08/10/14 03:15, Sandy Harris wrote:
> As I see it, though, and wrote in one thread:
> 
> " A real fix would make memset() do the right thing reliably; if the
> " programmer puts in memset( x, 0, nbytes) then the memory should
> " be cleared, no ifs or buts. I do not know or care if that means
> " changes in the compiler or in the library code or even both, but
> " the fix should make the standard library code work right, not
> " require adding a new function and expecting everyone to use it.
> 
> It seemed worth tossing this out for comment here.

That's not going to happen, given that memset_s() is a standard
idiom for this operation.

As it stands, even a call to memset_s() isn't sufficient: another
thread may not observe the memset_s() until a barrier has been
executed (and maybe not even then!) but I suppose it's better than
nothing.

Andrew.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]