STL bug in VS.NET 2002

  • Thread starter Antonio Maiorano
  • Start date
A

Antonio Maiorano

Hi everyone,

I use Visual Studio .NET 2002 right now, and I discovered a bug last night
that I have found few references to on the internet. Basically, if you
allocated a null-terminated char array that is 16 bytes or longer to
std::string, it stores garbage into it:

std::string s = "1234567890123456";

I tried this on .NET 2003 at work, and this bug has been fixed. Indeed, I
stepped into the string code, and found the difference somewhere in
<xstring>.

Anyway, my question is: what do I do? Do I really have to remove 2002 and
install 2003? Is there an bug-free STL implementation that I can download
somewhere and use instead? I have found no mention of this bug on M$ website
(big surprise).

Thank you for your time,

Tony
 
T

Thore Karlsen

Hi everyone,

I use Visual Studio .NET 2002 right now, and I discovered a bug last night
that I have found few references to on the internet. Basically, if you
allocated a null-terminated char array that is 16 bytes or longer to
std::string, it stores garbage into it:

std::string s = "1234567890123456";

I tried this on .NET 2003 at work, and this bug has been fixed. Indeed, I
stepped into the string code, and found the difference somewhere in
<xstring>.

Anyway, my question is: what do I do? Do I really have to remove 2002 and
install 2003? Is there an bug-free STL implementation that I can download
somewhere and use instead? I have found no mention of this bug on M$ website
(big surprise).

It's not a bug. Strings 16 characters or shorter are stored in the
object, while longer strings are stored on the heap. The debugger just
doesn't show the heap-allocated strings by default.
 
M

Mike Wahler

Antonio Maiorano said:
Hi everyone,

I use Visual Studio .NET 2002 right now, and I discovered a bug last night
that I have found few references to on the internet. Basically, if you
allocated a null-terminated char array that is 16 bytes or longer to
std::string, it stores garbage into it:

std::string s = "1234567890123456";

What specific code did you use that caused you to come to this
conclusion?
I tried this on .NET 2003 at work, and this bug has been fixed.

I'm not yet convinced you've discovered a bug.
Indeed, I
stepped into the string code, and found the difference somewhere in
<xstring>.

Difference between what and what?
Anyway, my question is: what do I do?

First confirm that there really is a bug.
Do I really have to remove 2002 and
install 2003? Is there an bug-free STL implementation that I can download
somewhere and use instead? I have found no mention of this bug on M$ website
(big surprise).

I don't see you referring to any particular 'bug.'
What behavior are you getting with what code that
causes you to cry 'bug'?

-Mike
 
P

P.J. Plauger

I use Visual Studio .NET 2002 right now, and I discovered a bug last night
that I have found few references to on the internet. Basically, if you
allocated a null-terminated char array that is 16 bytes or longer to
std::string, it stores garbage into it:

std::string s = "1234567890123456";

I tried this on .NET 2003 at work, and this bug has been fixed. Indeed, I
stepped into the string code, and found the difference somewhere in
<xstring>.

Anyway, my question is: what do I do? Do I really have to remove 2002 and
install 2003? Is there an bug-free STL implementation that I can download
somewhere and use instead? I have found no mention of this bug on M$ website
(big surprise).

The bug is in the debugger, which fails to display long strings properly.
(We use the Small String Optimization from V7.0 onward.) The strings
themselves are correct.

P.J. Plauger
Dinkumware, Ltd.
www.dinkumware.com
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,014
Latest member
BiancaFix3

Latest Threads

Top