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] |
Do you mean this works:
std::string getString();
void f() { const char* p = getString().c_str(); // use p }
? It shouldn't work ... or rather, you are not allowed to rely on it working because the destructor for the string will be run immediately after the assignment to p, which means p is invalidated. This sounds like the behaviour you're seeing, and is correct.
I set my debugger to break on free() and watched what was going on and in doing so I noticed that std::string uses its own deconstructor
(I'm assuming you mean the destructor, not some other function that does
de-construction)
that was different to the one my specialization was using. This leads me to believe that there are some differences implemented in std::string that I have not applied to my own specialization.
Have you written an explicit specialisation of basic_string<uint16_t>
or implicitly specialised it by instantiating it? You shouldn't need to
write an explicit specialisation of basic_string, only the char_traits
and other parts you mentioned already.
So, the next thing I wanted to do was to find this code, but after looking hard at everything i have I couldn't locate any extra code. So next I tried enabling debug mode in libstdc++ to see If i could step into the std::string stuff and see for myself what was going
Libstdc++ debug mode is not for stepping through the code in a debugger.
The debug mode adds extra checks and bookkeeping that catch errors and
misuses. The intent is to help debug your program, but not necessarily
by using a debugger (in many cases using the debug mode makes it clear
what the error is without ever having to start a debugger - which is
nice)
on. No go. So lastly I used darwinsource to build a debug version
What does that mean?
Did you use the --enable-libstdcxx-debug configuration option when
building GCC? That is the recommended way to get a debug version of the
library (i.e. one built with debugging symbols) but I don't know if it's
the right way for Mac OS X.
of libstdc++ and forced DYLD to link it in at runtime. When i debug my app, as before I can step into the constructor etc for my own specialization but not for std::string!
Sounds like you didn't link to the debug version then. std::string is
instantiated in the library, so if the library has debugging symbols you
*should* be able to step through in the debugger.
You can cause std::string to be instantiated in your application by
compiling with -D_GLIBCXX_EXTERN_TEMPLATE=0 which will prevent the
std::string instantiation from being suppressed in your app. That might
work in letting you step through the std::string code in a debugger
without having to recompile the library.
What I want to know is a: is there extra code for the std::string speciazation that I am missing? (if so where might i find it) and b: how can i get a version of libstdc++ that lets me step into this stuff? Surely this is possible or else, how do you guys actually develop the stuff in the first place!?
I hope I've answered b: above, the answer to a is no, there is no explicit specialisation of basic_string<char> - the explicitly specialised parts are char_traits etc. and a couple of overloads for operator>> and getline() for basic_string<char>
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |