This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc 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: [RFC] strcpy optimizations


On Tue, 29 Jan 2013, Paul Eggert wrote:

> On 01/29/13 13:53, OndÅej BÃlka wrote:
> > I wanted to use it only to bytes which change.
> 
> Sorry, I don't follow.
> 
> > There is problem with code like this:
> > struct foo {
> >   long x;
> >   char y[8];
> >   long z;
> > }
> > foo f;
> > 
> > With f.x++;              in first thread
> > With f.z++;              in second thread
> > and  strcpy (f.y, "abc") in third thread.
> 
> The behavior of strcpy is undefined in that case.

f.x, f.y and f.z are separate memory locations (as defined in C11 3.14), 
so I believe those updates in separate threads are valid according to the 
C11 memory model.

-- 
Joseph S. Myers
joseph@codesourcery.com

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