   splint and files.
  I'm trying to learn to use splint.#include <stdio.h>int main(void)   /*@globals fileSystem,errno@*/   /*@modifies fileSystem,errno@*/ {  FILE *file = fopen("FILE", "r");    if(file != NULL)   {    errno = 0;    /* (void)fclose(file); No complaints about this not happening. */   }    return 0; }Is there a reason why it isn't complaining about me not calling fclose?I suspect the reason is somehow related to the reason it isn't happy with this:#include <stdio.h>int main(void)   /*@globals fileSystem,errno@*/   /*@modifies fileSystem,errno@*/ {  /* !!! ERROR !!! Dependent storage is transferred to a non-dependent reference. */  /*@only@*/ FILE *file = fopen("FILE", "r");    if(file != NULL)   {    errno = 0;    (void)fclose(file);   }    /* !!! ERROR !!!Only storage file not released before returnA memory leak has been detected. Only-qualified storage is not releasedbefore the last reference to it is lost. */  return 0; }
Quote:Is there a reason why it isn't complaining about me not calling fclose?Because it's not needed. Streams will be closed automatically on exit.   ;  That's as silly as saying releasing memory isn't necessary, because it will be released when you exit.   ;  Nope, it's different, because the standard doesn't say anything about what happens to allocated memory (or at least I can't find it). The host environment usually destroys the whole program's address space, but this is implementation defined. However it guarantees that open streams are flushed and closed and temporary files are removed. Leaving streams open is formal correct, although of course it's bad style. ;)   