This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
Re: [PATCH] Slightly better way to __USE_MALLOC
- From: Loren James Rittle <rittle at latour dot rsch dot comm dot mot dot com>
- To: libstdc++ at gcc dot gnu dot org
- Cc: spencer at infointeractive dot com
- Date: Thu, 10 Oct 2002 17:46:08 -0500 (CDT)
- Subject: Re: [PATCH] Slightly better way to __USE_MALLOC
- Organization: Networks and Infrastructure Lab (IL02/2240), Motorola Labs
- References: <20021008181112.P3262@infointeractive.com>
> 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