Memory leak and shared libraries

I have recently posted this question but somehow it seems to have vanished.
So here it comes again:

Hello. I have had a tricky memory-leak that I have tracked down to some
strange behaviour in the qcc (compiler and/or linker).

I build my shared library with:
qcc -O1 -shared tree.cpp -o

Then I build the executable by doing:
qcc -O1 -c cnftest.cpp
qcc -lang-c++ -L . -ltree cnftest.o -o cnftest

If I now run my ‘cnftest’ program I will get a memory leak (which ofcourse
could depend on a coding error in my code, but it doesn’t).

If I instead build my executable using -fPIC it runs without a memory leak:
qcc -O1 -c -fPIC cnftest.cpp
qcc -lang-c++ -L . -ltree cnftest.o -o cnftest

I can also get rid of the memory leak by compiling tree.cpp to tree.o
(instead of using, in other words not use a shared library at

I can live with compiling with -fPIC, but I’m interested in hearing if this
is a known problem described somewhere?
I cannot see the connection between using -fPIC and a memory leak.

For information I’m using STL (string and vector) in my tree.cpp code.
Otherwise it is very simple. I can provide the source code to anyone (at
QNX?) that might be interested to find out what is going wrong.

Regards, Mats P