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: iostream changes locale to format a number


On May 3, 2002 10:00 am, Paolo Carlini wrote:
>
> Stephen I have tested Takeshi's testcase with today's 3.1 and the
> problem it's there! Of course it's there because __convert_from_v
> it's not ok!

A closer reading of __convert_from_v shows the only thing in between 
the set and restore setlocale is a sprintf.  I wouldn't expect sprintf 
to modify the current locale, but the XPG4 spec is explicitly vague 
about the nature of the string returned by setlocale, so it's not out 
of the question that sprintf might alter the value at the address 
returned by setlocale.  This should be easy to confirm (if changing 
locales doesn't core on you).

In short, you're right.  The only way to be 100% safe is to copy the 
string.  There are 24 instances of this behaviour throughout the C++ 
standard library.  I'd offer my services but I think I'm looking at a 
painful system restore over the next little while....

-- 
Stephen M. Webb


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