Re: automatic arrays with negative size in g95 and gfortran
- From: robert.corbett@xxxxxxx
- Date: 12 Jun 2006 20:30:29 -0700
glen herrmannsfeldt wrote:
For comparison purposes, the argument to malloc() in most C libraries
is unsigned, so a negative value will be treated as a very large
positive value. Even worse, many will return zero (NULL) when the
argument is zero, a request to allocate a zero size array. Since NULL
is returned when the allocation failed, the program will normally assume
it failed, and treat it appropriately. Some, it seems, treat a request
of zero as a request for 2**32 bytes (on 32 bit systems) which usually
fails.
No, the C standard allows that behavior. Some (misguided) people
think it is a good idea. The specific language of the C standard is
If the size of the space requested is zero, the behavior is
implementation-defined: either a null pointer is returned,
or the behavior is as if the size were some nonzero value,
except that the returned pointer shall not be used to access
an object.
Bob Corbett
.
- Follow-Ups:
- Re: automatic arrays with negative size in g95 and gfortran
- From: glen herrmannsfeldt
- Re: automatic arrays with negative size in g95 and gfortran
- References:
- automatic arrays with negative size in g95 and gfortran
- From: beliavsky
- Re: automatic arrays with negative size in g95 and gfortran
- From: Richard E Maine
- Re: automatic arrays with negative size in g95 and gfortran
- From: glen herrmannsfeldt
- automatic arrays with negative size in g95 and gfortran
- Prev by Date: Re: g77: 32-bit to 64-bit
- Next by Date: Re: g77: 32-bit to 64-bit
- Previous by thread: Re: automatic arrays with negative size in g95 and gfortran
- Next by thread: Re: automatic arrays with negative size in g95 and gfortran
- Index(es):
Relevant Pages
|
|