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,233 of 33,346   
   Daniel James to Edward Rosten   
   Re: stl clear and erase.   
   02 May 12 12:10:03   
   
   16757d27   
   From: daniel@me.invalid   
      
   In article   
   <9e1ed9de-2aa1-49fb-9dd4-c99d9d205a98@v2g2000vbv.googlegroups.com>,   
   Edward Rosten wrote:   
   > Note that there isn't a single instruction emitted between BEFORE and   
   > AFTER, in other words, the call to erase is entirely erased.   
      
   That, surely, is only possible here because the optimizer can tell that   
   the vector i is not accessed after the call to erase, so optimizing   
   away the clear will not change the observable behaviour of the program.   
      
   On a related note, I am often in the position of wanting to delete   
   (overwrite) the contents of a container before deleting it (e.g.   
   because those contents represent a password or cryptographic key that I   
   don't want to leave lying around in memory).   
      
   The trouble is: the optimizer is free to remove the code that is   
   supposed to perform the overwrite because it can see that the next   
   operation on the container will be to delete it. That is a piece of   
   optimizer 'helpfulness' that can be difficult to defeat!   
      
   --   
   Regards,   
     Daniel.   
   [Lest there be any confusion I am NOT the Boost maintainer of the same   
   name]   
      
      
         [ 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