[J3] Question about enum input

Malcolm Cohen malcolm at nag-j.co.jp
Mon Mar 27 01:14:39 UTC 2023

Hi Van,



Subclause "Integer editing" says that if the effective item for input is of enum type, the value assigned is the enum value corresponding to the value of the input field.



This is correct and what we want.


> The values of enumerators of ENUM type are not required to be consecutive


A red herring. 7.6.1 states

  “The set of values of an enum type has a one-to-one correspondence with the set of possible values for the integer kind of its enumerators.”


>Or is a variable of ENUM type allowed to have a numeric value that is not the numeric value of any enumerator of the type?





For input of ENUMERATION type, the value is required to be greater than zero and not greater than the number of enumerators of the type. What happens if the value is outside that range? Does an error condition exist or is the program simply not standard conformant?



Not conforming. That is what violating “shall” means.


>12.22.2p2 "Occurrence of input/output conditions" says that the set of input/output error conditions is processor dependent, so it appears that a processor is not required to detect these conditions.


The first is not an error. In the second, the program is not conforming. The processor can do anything it wants, for example,

a.	it could error-terminate the program,
b.	it could raise an i/o error condition,
c.	it could assign an invalid value to the enumeration variable,
d.	it could send a strongly-worded email to the Times.


Perhaps we ought to have mandated (b) by saying that an out-of-range input value raises an i/o error condition. But we did not.




..............Malcolm Cohen, NAG Oxford/Tokyo.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.j3-fortran.org/pipermail/j3/attachments/20230327/a91666ac/attachment.htm>

More information about the J3 mailing list