Thanks for the fix! However, adding the destructor to Wstring.h breaks my compiler. This gets barfed up, I assume from the linker:
o: In function `main':
undefined reference to `__dso_handle'
Removing the destructor from Wstring.h clears up the error, but I'm left with the memory leak. My sketch is driving a VFD module, and I am implementing a virtual display shift function in software since there is no hardware support. I am creating a new String for every shift (going for a rtl scroll effect). The leak fills up my SRAM within a few seconds freezing the Arduino.
I've done quite a bit of googling and information about this error is sparse. A few results said it had something to do with using ld for linking, criticizing it, and recommending I link with gcc instead. I have no idea how to make that happen. Another suggestion was found in a comment following a dso_handle definition:
// Versions of gcc/g++ after 3.0 (approx.), when configured for Linux
// native development (specifically, --with-__cxa_enable), have
// additional dependencies related to the destructors for static
// objects. When compiling C++ code with static objects the compiler
// inserts a call to __cxa_atexit() with __dso_handle as one of the
// arguments. __cxa_atexit() would normally be provided by glibc, and
// __dso_handle is part of crtstuff.c. Synthetic target applications
// are linked rather differently, so either a differently-configured
// compiler is needed or dummy versions of these symbols should be
// provided. If these symbols are not actually used then providing
// them is still harmless, linker garbage collection will remove them.
__cxa_atexit(void (*arg1)(void*), void* arg2, void* arg3)
void* __dso_handle = (void*) &__dso_handle;
I have tried adding the dummy symbols, but it throws a multiple references to __dso_handle error. Either it's undefined, or defined more than once. :-?
I am lost. I suspect a misconfigured/miscompiled gcc, but I just don't know. I haven't had an issue until now.
I am using Arduino 0017. I run stock openSUSE 11.0, with stock gcc packages from the main repos. I noticed that gcc and avr-gcc are reporting two different versions of gcc. Could that be a problem? Both packages appear to be current; I am subscribed to the main update repo and there are no updates available.
gcc -v: gcc version 4.3.1 20080507 (prerelease) [gcc-4_3-branch revision 135036] (SUSE Linux)
avr-gcc -v: gcc version 4.3.3 [gcc-4_3-branch revision 144878] (SUSE Linux)
Any ideas? Thanks.