J3/01-211 To: J3 From: Malcolm Cohen Subject: Interp request on the NULL intrinsic. Date: 21st May 2001 ------------------------------------------------------------------------------- NUMBER: ? TITLE: NULL intrinsic in initialization expressions KEYWORDS: NULL intrinsic, initialization expressions DEFECT TYPE: Erratum STATUS: J3 consideration in progress QUESTION: Section 7.1.6.1 says that an initialization expression may contain "(6) A reference to the transformational intrinsic function NULL," with no constraints on its argument. Therefore PROGRAM EXAMPLE CALL SUB(42) CONTAINS SUBROUTINE SUB(N) CHARACTER(N),POINTER :: CP INTEGER,PARAMETER :: M = LEN(NULL(CP)) REAL,SAVE :: X(M) END SUBROUTINE END is apparently standard-conforming, but it is difficult to see how this can work in practice, particularly if SUB were called with different values for N. Should there not be some constraint on the argument of NULL in an initialization expression? ANSWER: Yes, a constraint is needed to force initialization expressions always to be constant. An edit is supplied to correct this oversight. DISCUSSION: There is a spectrum of fixes available. (a) [Simplest] Forbid NULL to have an argument in an initialization expression. - Allowing NULL with an argument in an initialization expression adds no functionality but does allow the user to make mistakes. (b) [Second simplest] Require the argument of NULL to be an initialization expression, like we do for SELECTED_INT_KIND et al. (c) [Most complicated] Require the argument of NULL not to be of type character with a "problematic" length, where problematic means assumed length or a non-initialization-expression length. This will require even more words in F2002 where we have parameterized derived types and allocatable length characters. EDITS: [94:12+] add to end of list item "where the argument is not of type character with a length that is assumed or defined by an expression that is not an initialization expression." SUBMITTED BY: Malcolm Cohen HISTORY: 01-211 m157 Submitted -------------------------------------------------------------------------------