http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47023
--- Comment #23 from janus at gcc dot gnu.org 2011-10-18 13:45:32 UTC --- (In reply to comment #22) > (In reply to comment #21) > > The question is also how SIZEOF should act on data pointers: > > Should it give the size of the pointer itself, or the size of the object it > > points to? > > The target/pointee. Reasoning: For your example, g95, gfortran, ifort and > pathf95 all print "2". That's also what gfortran claims to do at > http://gcc.gnu.org/onlinedocs/gfortran/SIZEOF.html Well, ok. "Wer lesen kann ist klar im Vorteil" ;) Then this is obviously a feature and not a bug. > Regarding (comment 19, comment 20): > print *,sizeof(proc) ! (1) -- prints 1 > print *,sizeof(pp) ! (2) -- prints 1 > print *,sizeof(pp(0.)) ! (3) -- prints 4 > > ifort rejects (1) and (2) and returns "4" for (3). I think gfortran should do > likewise. Returning the pointee size for scalar variables but the pointer size > of functions is also a bit odd. Ok, I agree that it's better to reject it under these circumstances. How about the following patch? Index: gcc/fortran/check.c =================================================================== --- gcc/fortran/check.c (revision 180134) +++ gcc/fortran/check.c (working copy) @@ -3446,8 +3446,15 @@ gfc_check_size (gfc_expr *array, gfc_expr *dim, gf gfc_try -gfc_check_sizeof (gfc_expr *arg ATTRIBUTE_UNUSED) +gfc_check_sizeof (gfc_expr *arg) { + if (arg->ts.type == BT_PROCEDURE) + { + gfc_error ("'%s' argument of '%s' intrinsic at %L may not be a procedure", + gfc_current_intrinsic_arg[0]->name, gfc_current_intrinsic, + &arg->where); + return FAILURE; + } return SUCCESS; }