[PATCH] Fix backwards compatibility problem in libstdc++

Paolo Carlini pcarlini@suse.de
Fri Oct 13 18:20:00 GMT 2006


Hi Jakub,

>It seems the
>http://gcc.gnu.org/ml/libstdc++/2004-10/msg00394.html
>changes broke libstdc++ backwards compatibility, some GCC 3.4.x compiled
>programs and/or libraries misbehave with GCC 4.0.x and later libstdc++.so.6.
>The problem is if some 3.4.x program/library has an inlined copy of
>_S_construct or _M_clone (that means it initializes _M_length and
>_M_refdata's last char, but not _M_refcount) and calls out of line
>_S_create (which in GCC 3.4.x used to clear _M_refcount, but after
>the above patch it no longer does), then _M_refcount is uninitialized.
>When running 3.4.x code against 3.4.x libstdc++ or 4.[01].x code against
>4.[01].x libstdc++ there is no problem, in the first case _M_refcount
>is initialized in _S_create, in the latter in _S_construct/_M_clone that
>call it.
>  
>
Sob :(

>I'm afraid the only safe fix is now to clear _M_refcount in _S_create
>in addition to clearing it in its callers (well, it is just one int/long
>store, so it shouldn't slow things that much).
>
>Ok for trunk/4.1/4.0?
>  
>
Yes, certainly ok for now, we can always try to figure out something a 
tad cleaner at a later stage (the comment is very appropriate indeed).

Thanks,
Paolo.



More information about the Libstdc++ mailing list