https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66043
--- Comment #2 from Steve Kargl <sgk at troutmask dot apl.washington.edu> --- On Thu, May 07, 2015 at 03:52:24PM +0000, kargl at gcc dot gnu.org wrote: > > Index: check.c > =================================================================== > --- check.c (revision 222869) > +++ check.c (working copy) > @@ -6243,6 +6243,16 @@ gfc_check_and (gfc_expr *i, gfc_expr *j) > bool > gfc_check_storage_size (gfc_expr *a, gfc_expr *kind) > { > + if (a->expr_type == EXPR_NULL) > + { > + gfc_error ("%qs argument of %qs intrinsic at %L shall not be an " > + "unallocated allocatable variable or a disassociated or " > + "undefined pointer", > + gfc_current_intrinsic_arg[0]->name, gfc_current_intrinsic, > + &a->where); > + return false; > + } > + > if (a->ts.type == BT_ASSUMED) > { > gfc_error ("%qs argument of %qs intrinsic at %L shall not be TYPE(*)", > > The above patch is good enough to catch the direct use of NULL() in storage_size. The following should also be rejected: program p real, allocatable :: a real, pointer :: b => null() print *, storage_size(a) ! unallocated allocatable print *, storage_size(b) ! disassociated pointer end program p For 'b' we need to check a->symtree->n.sym->attr && a->symtree->n->sym.value->expr_type = EXPR_NULL For 'a', something similar is needed.