[PATCH] Slightly better way to __USE_MALLOC
Loren James Rittle
rittle@latour.rsch.comm.mot.com
Thu Oct 10 15:47:00 GMT 2002
> You are compiling some objects with the macro and some without, I
> presume. If you could post it (or send it to me directly), I'll see
> what I can do about it.
OK, you said that you had an example, but this is exactly what we want
to avoid (by catching at compile-time):
//a.C
#include <list>
void foo (std::list<int>& a)
{
a.pop_back ();
}
//b.C
#include <list>
void foo (std::list<int>& a);
int main (void)
{
std::list<int> a;
a.push_back (1);
foo (a);
}
(with library headers edited to remove the #error I added)
S rittle@latour; /usr/local/beta-gcc/bin/g++ -O2 -c -D__USE_MALLOC a.C
S rittle@latour; /usr/local/beta-gcc/bin/g++ -O2 b.C a.o
S rittle@latour; a.out
a.out in free(): warning: modified (chunk-) pointer
Other systems will crash@run-time with or without that helpful
message...
Regards,
Loren
More information about the Libstdc++
mailing list