Skip to content

Instantly share code, notes, and snippets.

@14NGiestas
Last active July 23, 2021 11:57
Show Gist options
  • Save 14NGiestas/78150b1feed3b5f54e9b68b698e340ad to your computer and use it in GitHub Desktop.
Save 14NGiestas/78150b1feed3b5f54e9b68b698e340ad to your computer and use it in GitHub Desktop.
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-pc-linux-gnu/11.1.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: /build/gcc/src/gcc/configure --prefix=/usr --libdir=/usr/lib --libexecdir=/usr/lib --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=https://bugs.archlinux.org/ --enable-languages=c,c++,ada,fortran,go,lto,objc,obj-c++,d --with-isl --with-linker-hash-style=gnu --with-system-zlib --enable-__cxa_atexit --enable-cet=auto --enable-checking=release --enable-clocale=gnu --enable-default-pie --enable-default-ssp --enable-gnu-indirect-function --enable-gnu-unique-object --enable-install-libiberty --enable-linker-build-id --enable-lto --enable-multilib --enable-plugin --enable-shared --enable-threads=posix --disable-libssp --disable-libstdcxx-pch --disable-libunwind-exceptions --disable-werror gdc_include_dir=/usr/include/dlang/gdc
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 11.1.0 (GCC)
program main
implicit none
real, allocatable :: x(:)
block
x = dummy(40)
print*, 'Allocated? ', allocated(x)
print*, 'Size? ', size(x)
end block
block
x = dummy(0)
print*, 'Allocated? ', allocated(x)
print*, 'Size? ', size(x)
end block
block
x = dummy(-100)
print*, 'Allocated? ', allocated(x)
print*, 'Size? ', size(x)
end block
print*, 'Size, unallocated: ', size(x)
contains
function dummy(n) result(res)
integer, intent(in) :: n
real :: res(n)
if (n <= 0) return
if (n == 1) then
res(1) = 2.0
return
end if
end function
end program
ian > corvette > ~  gfortran main.f90 && ./a.out
Allocated? T
Size? 40
Allocated? T
Size? 0
Allocated? F
Size? 0
Size, unallocated: 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment