• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Turning off 'deleting 'VOID*' is undefined' error
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Turning off 'deleting 'VOID*' is undefined' error


  • Subject: Re: Turning off 'deleting 'VOID*' is undefined' error
  • From: Laurence Harris <email@hidden>
  • Date: Mon, 29 Jan 2007 14:08:12 -0500


On Jan 29, 2007, at 4:58 AM, Laurence Harris wrote:


On Jan 29, 2007, at 1:56 AM, Mike wrote:

Porting a bunch of Windows C++ (which I didn't write) to Xcode.

Apparently a void* is being used as a field of a struct which holds a ptr to an object and the actual object type (class) can vary.

I believe the "right" way is to use a pointer to a base class that all the possible objects share. What you have currently is the kind of thing that requires lies to the compiler

I assumed (I should be flogged) that the code casts the void* when calling delete so any destructors can be called if they have any. If these objects have destructors that need to be called and the code isn't casting the pointer, then as others have said, those destructors aren't being called, so that would be a serious design- induced bug.


Even if the objects have no destructors that need to be called this is still a bug waiting to happen down the road if anyone adds a destructor to any of those objects. Even if the code *is* casting, this is a bug waiting to happen if a new object is added to the list of those to which this pointer can point and the casting code isn't updated to take that into account.

So at best this is a dangerous practice because it requires knowledge and action on the part of the programmer that should not be necessary if he were to ever add a destructor to any of the objects or add a new object. At worse it's a bug because there are already destructors not being called, and it's the kind of bug that would be very hard to track down.

Larry

and prevents C++ from doing things it was designed to do for you.

Larry


Mike

Chris Espinosa wrote:

On Jan 28, 2007, at 7:25 PM, Mike wrote:

Is there a setting in Xcode 2.4.1 for turning off the

warning: deleting 'VOID*' is undefined

warning?

No, there isn't. The C++ standard says you can only delete() things allocated with new(), as delete() must call free() first. So the compiler cannot generate correct code for delete of a 'void *'. The warning is there to warn you that your code may be doing any number of unintended things.


What are you really trying to do?

Chris
_______________________________________________ Do not post admin requests to the list. They will be ignored. Xcode-users mailing list (email@hidden) Help/Unsubscribe/Update your email@hidden This email sent to lists@michael- amorose.com

_______________________________________________ Do not post admin requests to the list. They will be ignored. Xcode-users mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: This email sent to email@hidden

_______________________________________________ Do not post admin requests to the list. They will be ignored. Xcode-users mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: This email sent to email@hidden

_______________________________________________ Do not post admin requests to the list. They will be ignored. Xcode-users mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: This email sent to email@hidden
References: 
 >Turning off 'deleting 'VOID*' is undefined' error (From: Mike <email@hidden>)
 >Re: Turning off 'deleting 'VOID*' is undefined' error (From: Chris Espinosa <email@hidden>)
 >Re: Turning off 'deleting 'VOID*' is undefined' error (From: Mike <email@hidden>)
 >Re: Turning off 'deleting 'VOID*' is undefined' error (From: Laurence Harris <email@hidden>)

  • Prev by Date: Re: beep
  • Next by Date: Re: Anonymous namespace clashes
  • Previous by thread: Re: Turning off 'deleting 'VOID*' is undefined' error
  • Next by thread: Re: Turning off 'deleting 'VOID*' is undefined' error
  • Index(es):
    • Date
    • Thread