Watch, Follow, &
Connect with Us

Please visit our new home
community.embarcadero.com.


Welcome, Guest
Guest Settings
Help

Thread: Stack overflow when using a std::map with UnicodeString as key, in Release configuration.



Permlink Replies: 2 - Last Post: Nov 10, 2017 12:48 PM Last Post By: Rodrigo Gomez C... Threads: [ Previous | Next ]
Rodrigo Gomez C...

Posts: 29
Registered: 3/16/00
Stack overflow when using a std::map with UnicodeString as key, in Release configuration.
Click to report abuse...   Click to reply to this thread Reply
  Posted: Nov 4, 2017 10:18 AM
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
Greg Reese

Posts: 78
Registered: 7/15/05
Re: Stack overflow when using a std::map with UnicodeString as key, in Release configuration.
Click to report abuse...   Click to reply to this thread Reply
  Posted: Nov 10, 2017 5:35 AM   in response to: Rodrigo Gomez C... in response to: Rodrigo Gomez C...
Rodrigo,
What compiler are you using, BCC or CLANG, 32- or 64-bit?
Greg Reese
Rodrigo Gomez C...

Posts: 29
Registered: 3/16/00
Re: Stack overflow when using a std::map with UnicodeString as key, in Release configuration.
Click to report abuse...   Click to reply to this thread Reply
  Posted: Nov 10, 2017 12:48 PM   in response to: Greg Reese in response to: Greg Reese
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)

Server Response from: ETNAJIVE02