home bbs files messages ]

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 32,972 of 33,346   
   Balog Pal to Francis Glassborow   
   Re: Sequence container capacity after ca   
   04 Apr 13 22:46:55   
   
   From: pasa@lib.hu   
      
   On 4/4/2013 6:02 AM, Francis Glassborow wrote:   
   > On 03/04/2013 18:28, Öö Tiib wrote:   
   >   
   >> I am not certain if needless memory management may be optimized out,   
   >> but I suspect that no. At least I haven't seen any C++ compilers   
   >> attempting to optimize that:   
   >>   
   >>     int main(){delete new char;}   
   >>   
   >> Everywhere it calls operator new and operator delete on whatever   
   >> optimization level despite to human eye it looks pointless to call   
   >> those. That means that dynamic memory management operations are   
   >> somehow considered externally observable behavior and so doing it   
   >> needlessly is doubly bad.   
   >   
   > It is quite hard to optimise these calls away because the new expression   
   > involves a call to operator new which may have been replaced by one that   
   > has some extra (observable) functionality. The same is true for the   
   > delete expression.   
      
   Hmm, an excellent point. And smells like a defect to the standard or at   
   least a good opportunity for improvement.   
      
   To me that case is the same as copy-elision. For that the standard   
   grants a license to remove a cctor/dtor pair despite it can be   
   user-defined and can have observable behavior.  The supposed semantics   
   suggest the actions shall cancel out properly.   
      
   Is there a reason the same license to eliminate could not be provided   
   for op new/delete pair?   
      
      
   --   
         [ 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