On Wed, 25 May 2005, REH wrote:
[color=blue]
>
> "Billy Patton" <bpatton@ti.com> wrote in message
> news:Pine.LNX.4.61.0505251429310.9493@holster07.da l.design.ti.com...[color=green]
>> If I comment out all down to the first fprintf , 6 lines. no problem
>> I uncommented one at a time until just the std::string* sp3 was commented[/color]
> out[color=green]
>> and still everything went ok.
>> When I uncomment that line I get a seg fault.
>>
>> Here's the core bt:
>> Core was generated by `Linux/32/test'.
>> Program terminated with signal 11, Segmentation fault.
>> #0 0x0811bb55 in _int_malloc ()
>> (gdb) bt
>> #0 0x0811bb55 in _int_malloc ()
>> #1 0x0811b58a in malloc ()
>> #2 0x080efd9e in operator new (sz=137509408)
>> at[/color]
> /apps/local-source/gcc/gcc-3.4.1/libstdc++-v3/libsupc++/new_op.cc:48[color=green]
>> #3 0x080662e2 in t_String () at test.cxx:1971
>> #4 0x0804836d in main (argc=1, argv=0xbfff84f4) at test.cxx:87
>> (gdb) q
>>
>>
>> Notice #2 sz=137509408
>>
>> /************************************************** ******************
>> ************************* TEST OPERATOR != *************************
>> ************************************************** *****************/
>> {
>> String s1("ABC");
>> String s2("abc");
>> String* sp1 = new String("abc");
>> String* sp2 = new String("ABC");
>> std::string s3("abc");
>> std::string* sp3 = new std::string("abc");
>> fprintf(stderr,"%d\n",__LINE__);
>> std::string* sp4 = new std::string("ABC");
>> fprintf(stderr,"%d\n",__LINE__);
>> OK(s1 != s1);
>> NOK(s1 != s2);
>> NOK(s1 != sp1);
>> OK(s1 != sp2);
>> NOK(s1 != s3);
>> NOK(s1 != sp3);
>> OK(s1 != sp4);
>> delete sp1;
>> delete sp2;
>> delete sp3;
>> delete sp3;
>> s2 = 1;
>> NOK(s1 != (short)1);
>> OK(s2 != (short)1);
>> NOK(s1 != (long)1);
>> OK(s2 != (long)1);
>> NOK(s1 != (int)1);
>> OK(s2 != (int)1);
>>
>> }
>> LEAVE;
>> }
>>[/color]
> You are deleting sp3 twice.
>
> Your macros make reading your code confusing.
>
> REH[/color]
It makes no difference about deleting sp3 twice. It doesn't get that far.
It will not even get to the second fprintf.
___ _ ____ ___ __ __
/ _ )(_) / /_ __ / _ \___ _/ /_/ /____ ___
/ _ / / / / // / / ___/ _ `/ __/ __/ _ \/ _ \
/____/_/_/_/\_, / /_/ \_,_/\__/\__/\___/_//_/
/___/
Texas Instruments ASIC Circuit Design Methodology Group
Dallas, Texas, 214-480-4455,
b-patton@ti.com