[Bug fortran/20520] New: allocatable arrays may be used without being allocated
The compiler does not display an error message when in a source file allocatable arrays are being used without having been allocated beforehand. For example, the following code is erroneous, but nevertheless the compiler will compile (and build) it silently: real,allocatable:: a(:),b(:) a(1)=2*b(1) end Of course, the executable produced will collapse when run. The gfortran compiler used was the standalone package for Windows (downloaded as a zip archive). -- Summary: allocatable arrays may be used without being allocated Product: gcc Version: 4.0.0 Status: UNCONFIRMED Severity: normal Priority: P2 Component: fortran AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: ebertakis at gmail dot com CC: gcc-bugs at gcc dot gnu dot org http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20520
[Bug fortran/20520] allocatable arrays used without being allocated without a warning
--- Additional Comments From ebertakis at gmail dot com 2005-03-17 19:07 --- (In reply to comment #1) I tried it in Compaq Visual Fortran Professional Edition 6.5 and indeed the compiler accepts the code. The debugger though will display an error message indicating the line "a(1)=2*b(1)" and saying that the array bounds were exceeded. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20520
[Bug fortran/20520] allocatable arrays used uninitialized without a warning
--- Additional Comments From ebertakis at gmail dot com 2005-03-20 19:22 --- (In reply to comment #4) This case is slightly different. The compiler just warns you that you are using variable x before its value have been defined. Many programmers (that have bad programming habits :-) probably that includes myself!) take for granted that variables have an initial value equal to 0 once their memory space is reserved upon definition as e.g. real. That is not always true and is heavily dependant on the compiler that is used. Many compilers fill the variables with garbage when they are first declared. See also the Fortran FAQ (paragraph 3.2.3): http://www.faqs.org/faqs/fortran-faq/ That is why you got that warning. I believe it is not related to the array usage. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20520