According to a std_files.e
that I have found, read_character
requires not end_of_file
, but it doesn't specify any post-condition; and last_character
has no preconditions. Therefore, what happens if you call last_character
before calling read_character
?
Asked
Active
Viewed 35 times
1

Eleno
- 2,864
- 3
- 33
- 39
-
I presume that in theory it is undefine and in practice, it has the default value of a {CHARACTER_8} object (i.e. 0). – Louis M Mar 15 '16 at 12:46
1 Answers
1
last_character
will give a default value '%U'
unless there is some unusual code around, e.g. the code that redefines this feature or accesses an object input
on STD_FILES
and reads something without using STD_FILES
, etc.

Alexander Kogtenkov
- 5,770
- 1
- 27
- 35
-
Therefore there is no way to detect a bug where a program calls `last_character` without having called `read_character` beforehand, right? – Eleno Mar 15 '16 at 13:40
-
Note that this is old code when attributes did not have the ability to have a contract. If we were to rewrite that code today, it would most likely have a precondition. – Emmanuel Stapf Mar 16 '16 at 09:44