This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ 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: Subtle MT problem with __gnu_cxx::hash_map


On Fri, Nov 19, 2004 at 03:45:24PM -0500, Paul Dubuc wrote:
> 
> 
> Matt Austern wrote:
> 
> >
> >
> >But operator[] isn't read access.  It's defined to be equivalent to a 
> >certain form of insert().
> 
> Not just insert() but find() too.  So it's both read and write access.  I 
> think there's enough ambiguity to warrant the simple change I suggested if 
> it's really feasible.

The problem Paul Dubuc has noted is that the expected failure is too 
uncertain, so that his code passed testing for too long before the
coding mistake was detected.

Thus, I would argue for opposite action: if it can be done without 
hurting performance for regular users, then any use of op[] should 
be very likely to fail when used in a shared context without locking 
-- regardless of whether the operation actually has any externally-
visible need to change the container.   Similarly, we should 
scribble the storage that was occupied by a container element, 
after it is removed.  It would probably be better to do this sort
of thing in a debug-mode version of the library.

It does users no favors to make their programs subtly less portable.

Nathan Myers
ncm-nospam@cantrip.org


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