https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90741
Bug ID: 90741 Summary: Unreachable second '__builtin_malloc' for scalar 'allocatable' Product: gcc Version: 10.0 Status: UNCONFIRMED Severity: enhancement Priority: P3 Component: fortran Assignee: unassigned at gcc dot gnu.org Reporter: tschwinge at gcc dot gnu.org Target Milestone: --- Based on trunk r271854, I noticed that for the following simple Fortran code: program main implicit none integer, allocatable :: a allocate (a) a = 50 deallocate (a) end program main ... the following appears in the '-fdump-tree-original' dump: [...] a = (integer(kind=4) *) __builtin_malloc (4); if (a == 0B) { _gfortran_os_error (&"Allocation would exceed memory limit"[1]{lb: 1 sz: 1}); } } if (a != 0B) goto L.1; a = (integer(kind=4) *) __builtin_malloc (4); L.1:; *a = 50; if (a == 0B) { _gfortran_runtime_error_at (&"At line 9 of file [...]"[1]{lb: 1 sz: 1}, &"Attempt to DEALLOCATE unallocated \'%s\'"[1]{lb: 1 sz: 1}, &"a"[1]{lb: 1 sz: 1}); } else { __builtin_free ((void *) a); } a = 0B; } I have not looked up where/why that second '__builtin_malloc' is emitted. At least in this simple case, it's unreachable, so it's not a memory leak.