public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/65684] New: Wrong error message when writing to a string
@ 2015-04-07 11:27 a.vogt at fulguritus dot com
2015-04-07 11:29 ` [Bug fortran/65684] " a.vogt at fulguritus dot com
` (10 more replies)
0 siblings, 11 replies; 12+ messages in thread
From: a.vogt at fulguritus dot com @ 2015-04-07 11:27 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65684
Bug ID: 65684
Summary: Wrong error message when writing to a string
Product: gcc
Version: 4.9.3
Status: UNCONFIRMED
Severity: minor
Priority: P3
Component: fortran
Assignee: unassigned at gcc dot gnu.org
Reporter: a.vogt at fulguritus dot com
gfortran gives the wrong output when writing to a string that is too short:
Compiling and running this snippet
program test
implicit none
character(2) :: str
write(str,*) 100
print *, str
end program
results in
> At line 5 of file test.F90
> Fortran runtime error: End of record
ifort, on the other hand, gives the correct error message:
> forrtl: severe (66): output statement overflows record, unit -5, file Internal List-Directed Write
Could the gfortran error message be adjusted?
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug fortran/65684] Wrong error message when writing to a string
2015-04-07 11:27 [Bug fortran/65684] New: Wrong error message when writing to a string a.vogt at fulguritus dot com
@ 2015-04-07 11:29 ` a.vogt at fulguritus dot com
2015-04-07 16:24 ` kargl at gcc dot gnu.org
` (9 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: a.vogt at fulguritus dot com @ 2015-04-07 11:29 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65684
--- Comment #1 from Alexander Vogt <a.vogt at fulguritus dot com> ---
This is motivated by this post on Stack Overflow:
https://stackoverflow.com/questions/29489388/fortran-end-of-record-error-when-saving-a-variable/29490374#29490374
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug fortran/65684] Wrong error message when writing to a string
2015-04-07 11:27 [Bug fortran/65684] New: Wrong error message when writing to a string a.vogt at fulguritus dot com
2015-04-07 11:29 ` [Bug fortran/65684] " a.vogt at fulguritus dot com
@ 2015-04-07 16:24 ` kargl at gcc dot gnu.org
2015-04-07 16:47 ` a.vogt at fulguritus dot com
` (8 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: kargl at gcc dot gnu.org @ 2015-04-07 16:24 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65684
kargl at gcc dot gnu.org changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |kargl at gcc dot gnu.org
--- Comment #2 from kargl at gcc dot gnu.org ---
Your program is non-conforming. Technically, gfortran can
do anything. This includes not issuing any error message,
starting World War III, or issuing an error message. In fact,
gfortran's error message is correct to extent that the write
statement reaches the end-of-record.
If one takes the time to wander through the final committee
draft of the Fortran 2008 standard, then one can piece together
the story. The crucial text is the third bullet under Sec. 9.4.
9.2 Records
9.2.1 General
A record is a sequence of values or a sequence of characters.
9.4 Internal files
An internal file is a record file with the following properties.
* A record of an internal file is a scalar character variable.
* If the file is a scalar character variable, it consists of a
single record whose length is the same as the length of the
scalar character variable.
* A record of the internal file becomes defined by writing the
record. If the number of characters written in a record is
less than the length of the record, the remaining portion of
the record is filled with blanks. The number of characters
to be written shall not exceed the length of the record.
9.6.4 Execution of a data transfer input/output statement
9.6.4.1 General
....
(7) Determine whether an error, end-of-file, or end-of-record
condition has occurred.
....
(10) If an error, end-of-file, or end-of-record condition occurred,
processing continues as specified in 9.11; otherwise any
variable specified in an IOSTAT= specifier is assigned the
value zero.
9.11.4 End-of-record condition and the EOR= specifier
If an end-of-record condition occurs during execution of an
input/output statement that contains neither an EOR= specifier
nor an IOSTAT= specifier, error termination is initiated.
IMNSHO, this bug report should be closed as WONTFIX, but I'll
leave it open until others have a chance to comment.
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug fortran/65684] Wrong error message when writing to a string
2015-04-07 11:27 [Bug fortran/65684] New: Wrong error message when writing to a string a.vogt at fulguritus dot com
2015-04-07 11:29 ` [Bug fortran/65684] " a.vogt at fulguritus dot com
2015-04-07 16:24 ` kargl at gcc dot gnu.org
@ 2015-04-07 16:47 ` a.vogt at fulguritus dot com
2015-04-07 19:07 ` jvdelisle at gcc dot gnu.org
` (7 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: a.vogt at fulguritus dot com @ 2015-04-07 16:47 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65684
--- Comment #3 from Alexander Vogt <a.vogt at fulguritus dot com> ---
OK, I agree that the behavior is Standard conforming...
Thanks for the clarification!
Still, the error message issued is not really helpful if one is unfamiliar with
the Standard. Maybe it could be improved for more guidance (point towards the
overflow and maybe the Standard).
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug fortran/65684] Wrong error message when writing to a string
2015-04-07 11:27 [Bug fortran/65684] New: Wrong error message when writing to a string a.vogt at fulguritus dot com
` (2 preceding siblings ...)
2015-04-07 16:47 ` a.vogt at fulguritus dot com
@ 2015-04-07 19:07 ` jvdelisle at gcc dot gnu.org
2015-04-08 9:02 ` dominiq at lps dot ens.fr
` (6 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: jvdelisle at gcc dot gnu.org @ 2015-04-07 19:07 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65684
Jerry DeLisle <jvdelisle at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |jvdelisle at gcc dot gnu.org
Assignee|unassigned at gcc dot gnu.org |jvdelisle at gcc dot gnu.org
Severity|minor |enhancement
--- Comment #4 from Jerry DeLisle <jvdelisle at gcc dot gnu.org> ---
I agree we have no concern over compliance of gfortran here and the error
message is accurate. So this is not a bug, but a request to enhance the error
message in the case of the writing to a string. So, under the principle of
being helpful to users, I will be willing to do this. It will have to wait
until after the next release happens.
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug fortran/65684] Wrong error message when writing to a string
2015-04-07 11:27 [Bug fortran/65684] New: Wrong error message when writing to a string a.vogt at fulguritus dot com
` (3 preceding siblings ...)
2015-04-07 19:07 ` jvdelisle at gcc dot gnu.org
@ 2015-04-08 9:02 ` dominiq at lps dot ens.fr
2015-04-08 9:23 ` a.vogt at fulguritus dot com
` (5 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: dominiq at lps dot ens.fr @ 2015-04-08 9:02 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65684
Dominique d'Humieres <dominiq at lps dot ens.fr> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Last reconfirmed| |2015-04-08
Ever confirmed|0 |1
--- Comment #5 from Dominique d'Humieres <dominiq at lps dot ens.fr> ---
Honestly, do you really find that
> forrtl: severe (66): output statement overflows record, unit -5,
> file Internal List-Directed Write
is more helpful than
> At line 5 of file test.F90
> Fortran runtime error: End of record
?
Personally I don't. fortran directs the user to the line and file leading to
the run time error, then if the user does not understand what's wrong with
'write(str,*) 100', (s)he must really learn elementary Fortran.
> I agree we have no concern over compliance of gfortran here and the error
> message is accurate. So this is not a bug, but a request to enhance the error
> message in the case of the writing to a string. So, under the principle of
> being helpful to users, I will be willing to do this. It will have to wait
> until after the next release happens.
Several months ago I have browsed the bug list for fortran, libfortran (817
entries today) and I have seen about three dozens entries containing "message"
in their summary. I think a fraction of them are more urgent/easy to fix than
this one.
Now, if you really think this PR is important, nothing prevents you to submit a
patch!
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug fortran/65684] Wrong error message when writing to a string
2015-04-07 11:27 [Bug fortran/65684] New: Wrong error message when writing to a string a.vogt at fulguritus dot com
` (4 preceding siblings ...)
2015-04-08 9:02 ` dominiq at lps dot ens.fr
@ 2015-04-08 9:23 ` a.vogt at fulguritus dot com
2015-04-08 9:46 ` dominiq at lps dot ens.fr
` (4 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: a.vogt at fulguritus dot com @ 2015-04-08 9:23 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65684
--- Comment #6 from Alexander Vogt <a.vogt at fulguritus dot com> ---
Fair enough... I have no experience in coding for GCC. Could you give me a hint
where (which file) to start?
I would propose a message like
> At line 5 of file test.F90
> Fortran runtime error: End of record (number of characters to be written exceeds the length of the record)
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug fortran/65684] Wrong error message when writing to a string
2015-04-07 11:27 [Bug fortran/65684] New: Wrong error message when writing to a string a.vogt at fulguritus dot com
` (5 preceding siblings ...)
2015-04-08 9:23 ` a.vogt at fulguritus dot com
@ 2015-04-08 9:46 ` dominiq at lps dot ens.fr
2015-04-08 10:21 ` a.vogt at fulguritus dot com
` (3 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: dominiq at lps dot ens.fr @ 2015-04-08 9:46 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65684
--- Comment #7 from Dominique d'Humieres <dominiq at lps dot ens.fr> ---
> Fair enough... I have no experience in coding for GCC. Could you give me
> a hint where (which file) to start?
The content of the message is set by 'translate_error (int code)' (line 412 of
libgfortran/runtime/error.c).
> I would propose a message like
>
> > At line 5 of file test.F90
> > Fortran runtime error: End of record (number of characters to be written
> > exceeds the length of the record)
I did not looked further to the code (you can grep for LIBERROR_EOR
libgfortran/runtime/* libgfortran/io/*, and gcc/fortran/* to find where it is
set) but I am not sure that "End of record" cannot be emitted when reading or
for unformatted files. If so your message will be misleading.
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug fortran/65684] Wrong error message when writing to a string
2015-04-07 11:27 [Bug fortran/65684] New: Wrong error message when writing to a string a.vogt at fulguritus dot com
` (6 preceding siblings ...)
2015-04-08 9:46 ` dominiq at lps dot ens.fr
@ 2015-04-08 10:21 ` a.vogt at fulguritus dot com
2015-04-08 18:38 ` a.vogt at fulguritus dot com
` (2 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: a.vogt at fulguritus dot com @ 2015-04-08 10:21 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65684
--- Comment #9 from Alexander Vogt <a.vogt at fulguritus dot com> ---
Then, it would be as simple as passing generate_error the message instead of
NULL.
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug fortran/65684] Wrong error message when writing to a string
2015-04-07 11:27 [Bug fortran/65684] New: Wrong error message when writing to a string a.vogt at fulguritus dot com
` (7 preceding siblings ...)
2015-04-08 10:21 ` a.vogt at fulguritus dot com
@ 2015-04-08 18:38 ` a.vogt at fulguritus dot com
2015-04-09 12:24 ` jvdelisle at gcc dot gnu.org
2015-04-21 18:33 ` jvdelisle at gcc dot gnu.org
10 siblings, 0 replies; 12+ messages in thread
From: a.vogt at fulguritus dot com @ 2015-04-08 18:38 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65684
--- Comment #10 from Alexander Vogt <a.vogt at fulguritus dot com> ---
Created attachment 35263
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=35263&action=edit
Patch for more specific error messages
This is a suggestion for more verbose error messages... What do you think?
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug fortran/65684] Wrong error message when writing to a string
2015-04-07 11:27 [Bug fortran/65684] New: Wrong error message when writing to a string a.vogt at fulguritus dot com
` (8 preceding siblings ...)
2015-04-08 18:38 ` a.vogt at fulguritus dot com
@ 2015-04-09 12:24 ` jvdelisle at gcc dot gnu.org
2015-04-21 18:33 ` jvdelisle at gcc dot gnu.org
10 siblings, 0 replies; 12+ messages in thread
From: jvdelisle at gcc dot gnu.org @ 2015-04-09 12:24 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65684
--- Comment #12 from Jerry DeLisle <jvdelisle at gcc dot gnu.org> ---
I have another idea in mind, however I see what your aiming for. I sense some
frustration over personal preferences and wording and such. There is no rush
here, since we have to wait for next stage 1 regardless.
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug fortran/65684] Wrong error message when writing to a string
2015-04-07 11:27 [Bug fortran/65684] New: Wrong error message when writing to a string a.vogt at fulguritus dot com
` (9 preceding siblings ...)
2015-04-09 12:24 ` jvdelisle at gcc dot gnu.org
@ 2015-04-21 18:33 ` jvdelisle at gcc dot gnu.org
10 siblings, 0 replies; 12+ messages in thread
From: jvdelisle at gcc dot gnu.org @ 2015-04-21 18:33 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65684
Jerry DeLisle <jvdelisle at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Resolution|--- |WONTFIX
--- Comment #13 from Jerry DeLisle <jvdelisle at gcc dot gnu.org> ---
After giving this some consideration and with respect, I have decided to close
this as "WONtFIX". We have standardized the error messages in runtime/error.c
for probably over 10 years now and I think its best to leave it alone.
^ permalink raw reply [flat|nested] 12+ messages in thread
end of thread, other threads:[~2015-04-21 18:33 UTC | newest]
Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-04-07 11:27 [Bug fortran/65684] New: Wrong error message when writing to a string a.vogt at fulguritus dot com
2015-04-07 11:29 ` [Bug fortran/65684] " a.vogt at fulguritus dot com
2015-04-07 16:24 ` kargl at gcc dot gnu.org
2015-04-07 16:47 ` a.vogt at fulguritus dot com
2015-04-07 19:07 ` jvdelisle at gcc dot gnu.org
2015-04-08 9:02 ` dominiq at lps dot ens.fr
2015-04-08 9:23 ` a.vogt at fulguritus dot com
2015-04-08 9:46 ` dominiq at lps dot ens.fr
2015-04-08 10:21 ` a.vogt at fulguritus dot com
2015-04-08 18:38 ` a.vogt at fulguritus dot com
2015-04-09 12:24 ` jvdelisle at gcc dot gnu.org
2015-04-21 18:33 ` jvdelisle at gcc dot gnu.org
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).