diff mbox

[C++] Fix C++ violation in g++.jason/init3.C (PR testsuite/63299)

Message ID 20160919220430.GT7282@tucnak.redhat.com
State New
Headers show

Commit Message

Jakub Jelinek Sept. 19, 2016, 10:04 p.m. UTC
Hi!

As valgrind reports, this testcase allocates the string with new [], but
deallocates with delete str.

Fixed thusly, regtested on x86_64-linux and i686-linux, ok for trunk?

2016-09-19  Maxim Ostapenko  <m.ostapenko@samsung.com>
	    Jakub Jelinek  <jakub@redhat.com>

	PR testsuite/63299
	* g++.old-deja/g++.jason/init3.C (My_string::~My_string): Use delete[]
	instead of delete.


	Jakub

Comments

Jeff Law Sept. 20, 2016, 2:57 p.m. UTC | #1
On 09/19/2016 04:04 PM, Jakub Jelinek wrote:
> Hi!
>
> As valgrind reports, this testcase allocates the string with new [], but
> deallocates with delete str.
>
> Fixed thusly, regtested on x86_64-linux and i686-linux, ok for trunk?
>
> 2016-09-19  Maxim Ostapenko  <m.ostapenko@samsung.com>
> 	    Jakub Jelinek  <jakub@redhat.com>
>
> 	PR testsuite/63299
> 	* g++.old-deja/g++.jason/init3.C (My_string::~My_string): Use delete[]
> 	instead of delete.
OK.
jeff
diff mbox

Patch

--- gcc/testsuite/g++.old-deja/g++.jason/init3.C.jj	2008-09-05 12:54:52.000000000 +0200
+++ gcc/testsuite/g++.old-deja/g++.jason/init3.C	2016-09-19 16:06:01.328022761 +0200
@@ -10,7 +10,7 @@  class My_string {
 public:
    My_string(const char* string);
    My_string(const My_string &);
-   ~My_string() { delete str; }
+   ~My_string() { delete [] str; }
    char* char_p() { return str; }
 };