Forums before death by AOL, social media and spammers... "We can't have nice things"
|    comp.lang.c++.moderated    |    Moderated discussion of C++ superhackery    |    33,346 messages    |
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
|    Message 31,993 of 33,346    |
|    Wil Evers to Pete Becker    |
|    Re: Incomplete class with auto_ptr    |
|    07 Mar 12 01:01:48    |
      From: bouncer@dev.null              Pete Becker wrote:              > On 2012-03-06 06:15:41 +0000, rockeet said:       >       >> By standard, delete a pointer of incomplete type is not an error, it's       >> just a warning.       >       > The standard does not distinguish "error" from "warning". If code is       > ill-formed, it requires "a diagnostic". It is implementation-defined       > what constitutes a diagnostic. And after issuing a diagnostic, the       > implementation is free to do whatever the implementor decided,       > including carrying on with some implementation-specific behavior.       > The standard also does not prohibit issuing a diagnostic on valid       > code.              Sure, but in this case (a delete-expression on a pointer to an       incomplete type) the standard doesn't say the code is ill-formed.       Therefore, an implementation is not required to issue a diagnostic,       although, as you say, it is free to do so.              A more interesting question is whether, in this case, a conforming       implementation is allowed to refuse to compile the code. I think the       answer is no, unless the complete class of the object being deleted       has a non-trivial destructor or a deallocation function (that's       undefined behaviour, which allows the compiler to do anything).              And that's where the problem is: the type is incomplete, so in all       likelihood, the compiler just doesn't know. All it can do is warn       about of a case of *possibly* undefined behaviour.              Regards,              - Wil                     --        [ See http://www.gotw.ca/resources/clcm.htm for info about ]        [ comp.lang.c++.moderated. First time posters: Do this! ]              --- SoupGate-Win32 v1.05        * Origin: you cannot sedate... all the things you hate (1:229/2)    |
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
(c) 1994, bbs@darkrealms.ca