Optimization/clarity coding : what is gcc able to do for me ?

Joe Buck Joe.Buck@synopsys.COM
Mon Jan 17 17:09:00 GMT 2005


On Sat, Jan 15, 2005 at 04:21:23PM +0100, jlh wrote:
> 
> Nick NoSpam wrote:
> > So since one thread is reading (size() is a const method), and another may
> > be writing (perhaps adding new elements), it's fine for such implementations.
> 
> Only if you can ensure both operation to not happen at the same time.  If you
> call size() while another thread is just resizing the vector, you might get
> wrong results.

You are laboring under a mistaken impression: the C++ standard does not
require this level of thread safety and no C++ compiler or library
provider provides that kind of thread safety (as the cost would be
enormous for non-threaded programs).



More information about the Gcc mailing list