Thread: Stack overflow when using a std::map with UnicodeString as key, in Release configuration.
|
Replies:
2
-
Last Post:
Nov 10, 2017 12:48 PM
Last Post By: Rodrigo Gomez C...
|
|
|
Posts:
32
Registered:
3/16/00
|
|
I have a std::map using the following definition:
struct Totales
{
System::Currency SubTotal;
System::Currency IVA;
System::Currency Total;
Totales()
{
SubTotal = 0.0;
IVA = 0.0;
Total = 0.0;
}
};
typedef std::map< UnicodeString, Totales > TMapaTotales;
When compiling the project with the Debug configuration everything is good and everything
runs correctly. But when switching to the Release configuration (which as far as I can see
the only difference is that it uses the "Generate fastest possible code" option enabled)
then trying to use this map produces stack overflows, or just loops forever.
For instance, trying to call the .clear() member produces a stack overflow. If I skip that
call (the map is empty at that point) but then try to access it: mymap["some key"].Total =
0, then it cycles forever.
If I change the key to be an AnsiString instead of an UnicodeString then things work ok.
This is with C++Builder 10.1 Berlin, all patched up.
Anybody experiencing the same problem? It's no problem in this case to use AnsiString as
the key, but I don't feel confident of it not blowing up later for some unknown reason.
Thanks,
--
Rodrigo Gómez
|
|
|
Posts:
100
Registered:
7/15/05
|
|
Rodrigo,
What compiler are you using, BCC or CLANG, 32- or 64-bit?
Greg Reese
|
|
|
|
Posts:
32
Registered:
3/16/00
|
|
On 10/11/2017 07:35 a. m., Greg Reese wrote:
Rodrigo,
What compiler are you using, BCC or CLANG, 32- or 64-bit?
Greg Reese
Sorry, forgot to add that. It's the Classic BCC, 32 bits. I haven't tried with CLANG,
although even if it works there it's not of much use to me, as my app is still long way to
go before being able to use the new compiler.
Thanks,
--
Rodrigo Gómez
|
|
|
|
Legend
|
|
Helpful Answer
(5 pts)
|
|
Correct Answer
(10 pts)
|
|
Connect with Us