You are viewing a plain text version of this content. The canonical link for it is here.
Posted to c-dev@axis.apache.org by Emanuel Norrbin <em...@jitterbit.com> on 2007/05/31 22:04:28 UTC

deleting a void* is not defined

Hi,

I am working with the current version of the Axis C++ trunk and I see
this warning when I compile on Linux with gcc 3.4.4

       [cc] 120 total files to be compiled.
       [cc] 
/usr/local/tmp/emanuel/BUILD/ws-axis/obj/src/common/ArrayBean.cpp: In 
destructor `virtual axiscpp::ArrayBean::~ArrayBean()':
       [cc] 
/usr/local/tmp/emanuel/BUILD/ws-axis/obj/src/common/ArrayBean.cpp:329: 
warning: deleting `void*' is undefined

When I did a google search for "C++ delete void*" I found that the consensus
was that deleting a void* is a no-no in C++.

I also remember valgrind complaining about this when I ran it for memory 
leak checking.

The problem is on line 329 in ArrayBean.cpp with the following code:

   delete [] m_value.sta;

It seems that the ArrayBean class (judging from the switch statement 
above this)
knows the actual type of m_value.sta. Would it be feasable to introduce 
another
switch statement which casts m_value.sta to the correct type before 
deleting it?

Since I am not that familiar with the code maybe the issue is more 
complicated than
that or this may be a non-issue, but I can try it if you want to.

The reason I want to use the latest version of Axis C++ is that I am 
experiencing
crashes on Solaris when running the same code that I run on Linux 
without any problems,
but so far I have not tried it on the latest version.

/Cheers
Emanuel



---------------------------------------------------------------------
To unsubscribe, e-mail: axis-c-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-c-dev-help@ws.apache.org


Re: deleting a void* is not defined

Posted by Nadir Amra <am...@us.ibm.com>.
Emanuel,

Since we are deleting an array of pointers, the way this is coded is OK. 
There are no destructors to call.  The delete will release the storage by 
calling the global  ::operator delete[]()...I guess you compiler or C++ 
runtime does not do that.

How about trying 

delete [] (void **)m_value.sta;

Does that work?  If not, I can change to 

delete [] (char **)m_value.sta;

Kind of a hack....until this is cleared up. 

Nadir K. Amra


Emanuel Norrbin <em...@jitterbit.com> wrote on 05/31/2007 
03:04:28 PM:

> Hi,
> 
> I am working with the current version of the Axis C++ trunk and I see
> this warning when I compile on Linux with gcc 3.4.4
> 
>        [cc] 120 total files to be compiled.
>        [cc] 
> /usr/local/tmp/emanuel/BUILD/ws-axis/obj/src/common/ArrayBean.cpp: In 
> destructor `virtual axiscpp::ArrayBean::~ArrayBean()':
>        [cc] 
> /usr/local/tmp/emanuel/BUILD/ws-axis/obj/src/common/ArrayBean.cpp:329: 
> warning: deleting `void*' is undefined
> 
> When I did a google search for "C++ delete void*" I found that the 
consensus
> was that deleting a void* is a no-no in C++.
> 
> I also remember valgrind complaining about this when I ran it for memory 

> leak checking.
> 
> The problem is on line 329 in ArrayBean.cpp with the following code:
> 
>    delete [] m_value.sta;
> 
> It seems that the ArrayBean class (judging from the switch statement 
> above this)
> knows the actual type of m_value.sta. Would it be feasable to introduce 
> another
> switch statement which casts m_value.sta to the correct type before 
> deleting it?
> 
> Since I am not that familiar with the code maybe the issue is more 
> complicated than
> that or this may be a non-issue, but I can try it if you want to.
> 
> The reason I want to use the latest version of Axis C++ is that I am 
> experiencing
> crashes on Solaris when running the same code that I run on Linux 
> without any problems,
> but so far I have not tried it on the latest version.
> 
> /Cheers
> Emanuel
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: axis-c-dev-unsubscribe@ws.apache.org
> For additional commands, e-mail: axis-c-dev-help@ws.apache.org
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: axis-c-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-c-dev-help@ws.apache.org