[Bug c++/25735] New: Assignment operator broken with multidimensional array strings.

2006-01-10 Thread dtrebilco at gmail dot com
I am not sure if this is correct C++ code anyway, (so please correct me if not)

#include 
#include 

using namespace std;

struct TestStruct
{
  string testStr[2][2];
/*  
  TestStruct &operator= (const TestStruct &src)
  {
testStr[0][0] = src.testStr[0][0]; 
testStr[0][1] = src.testStr[0][1]; 
testStr[1][0] = src.testStr[1][0];  
testStr[1][1] = src.testStr[1][1];  

return *this;
  }
*/  
};

int main()
{
  TestStruct a, b;
  a.testStr[0][0] = "1234567890";
  b = a;

  printf("Done \n %s", b.testStr[0][0].c_str());
  return 0; 
}

With no assignment operator, the default generated one causes a "double free or
corruption" error. Single arrays work fine, but I am also unsure what the
correct C++ behaviour should be in this case.


-- 
   Summary: Assignment operator broken with multidimensional array
strings.
   Product: gcc
   Version: 3.4.2
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: dtrebilco at gmail dot com


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25735




[Bug c++/25735] Assignment operator broken with multidimensional array strings.

2006-01-10 Thread dtrebilco at gmail dot com


--- Comment #3 from dtrebilco at gmail dot com  2006-01-10 13:33 ---
(In reply to comment #2)
> (In reply to comment #1)
> > I cannot reproduce this in 3.4.0, 3.4.5 or 4.1.0.
> 
> Same here, mainline too. Valgrind is also fine, on x86.
> 

If it helps I am using compile options: -O0 -g3 -Wall -c -fmessage-length=0
with Compiler 3.4.2 20041017 (Red Hat 3.4.2-6.fc3) - Fedora Core 3 (x86)


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25735