------- Comment #10 from tobi at gcc dot gnu dot org  2006-01-10 00:10 -------
(In reply to comment #9)
> We don't get an error message but instead we call  _gfortran_internal_malloc
> with a zero value and invoked undefined behavior in malloc.

No.  This is specifically guarded against:

   69 /* Allocate memory for internal (compiler generated) use.  */
   70 
   71 void *
   72 internal_malloc_size (size_t size)
   73 {
   74   if (size == 0)
   75     return NULL;
   76 
   77   return get_mem (size);
   78 }
   79 
   80 extern void *internal_malloc (GFC_INTEGER_4);
   81 export_proto(internal_malloc);
   82 
   83 void *
   84 internal_malloc (GFC_INTEGER_4 size)
   85 {
   86 #ifdef GFC_CHECK_MEMORY
   87   /* Under normal circumstances, this is _never_ going to happen!  */
   88   if (size < 0)
   89     runtime_error ("Attempt to allocate a negative amount of memory.");
   90 
   91 #endif
   92   return internal_malloc_size ((size_t) size);
   93 }


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15335


Reply via email to