public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/66725] New: Issue with silent conversion int to char, struggling in gfc_widechar_to_char
@ 2015-07-01 16:28 gerhard.steinmetz.fortran@t-online.de
  2015-07-01 16:30 ` [Bug fortran/66725] " gerhard.steinmetz.fortran@t-online.de
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: gerhard.steinmetz.fortran@t-online.de @ 2015-07-01 16:28 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66725

            Bug ID: 66725
           Summary: Issue with silent conversion int to char, struggling
                    in gfc_widechar_to_char
           Product: gcc
           Version: 5.1.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: gerhard.steinmetz.fortran@t-online.de
  Target Milestone: ---

Sometimes a silent conversion from integer to character occurs
where it should not IMO, but should give an explicit error instead.
If this integer value n is too "large" (n > 255 or n < -255),
an ICE occurs (gfc_widechar_to_char).

This happens for several io statements and several specifiers.
An integer value at this place is wrong anyway.
Required is e.g. a scalar-default-char-expr.
Maybe wrong caret position is an aftereffect.


$ cat z_iostmt_status_257.f90
program p
   open (1, status=257)
end


$ gfortran -g -Wall -fcheck=all -fno-frontend-optimize z_iostmt_status_257.f90
f951: internal compiler error: in gfc_widechar_to_char, at
fortran/scanner.c:197


---

$ cat z_iostmt_status_100.f90
program p
   open (1, status=100)   ! wrong data type !<<<
end

$ gfortran -g -Wall -fcheck=all -fno-frontend-optimize z_iostmt_status_100.f90
z_iostmt_status_100.f90:2:48:

    open (1, status=100)   ! wrong data type !<<<
                                                1
Error: STATUS specifier in OPEN statement at (1) has invalid value 'd'


---

$ cat z_iostmt_asynchronous_999.f90
program p
   write (1, asynchronous=999)
end


$ gfortran z_iostmt_asynchronous_999.f90
f951: internal compiler error: in gfc_widechar_to_char, at
fortran/scanner.c:197


---

$ cat z_iostmt_asynchronous_104.f90
program p
   write (1, asynchronous=104)   ! wrong data type !<<<
end


$ gfortran z_iostmt_asynchronous_104.f90
z_iostmt_asynchronous_104.f90:2:55:

    write (1, asynchronous=104)   ! wrong data type !<<<
                                                       1
Error: ASYNCHRONOUS specifier in WRITE statement at (1) has invalid value 'h'


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug fortran/66725] Issue with silent conversion int to char, struggling in gfc_widechar_to_char
  2015-07-01 16:28 [Bug fortran/66725] New: Issue with silent conversion int to char, struggling in gfc_widechar_to_char gerhard.steinmetz.fortran@t-online.de
@ 2015-07-01 16:30 ` gerhard.steinmetz.fortran@t-online.de
  2015-07-02 21:40 ` [Bug fortran/66725] Issue with silent conversion int to char, ICE if int too large kargl at gcc dot gnu.org
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: gerhard.steinmetz.fortran@t-online.de @ 2015-07-01 16:30 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66725

--- Comment #1 from Gerhard Steinmetz <gerhard.steinmetz.fortran@t-online.de> ---
Whereas :


$ cat y_test_char_1.f90
program p
   print *, char(100)
end

$ gfortran y_test_char_1.f90
$ a.out
 d

---

$ cat y_test_char_2.f90
program p
   print *, char(257)
end

$ gfortran y_test_char_2.f90
y_test_char_2.f90:2:17:

    print *, char(257)
                 1
Error: Argument of CHAR function at (1) is too large for the collating sequence
of kind 1

---

$ cat y_test_char_3.f90
program p
   write (1, asynchronous=char(100))
end
$ gfortran y_test_char_3.f90
y_test_char_3.f90:2:36:

    write (1, asynchronous=char(100))
                                    1
Error: ASYNCHRONOUS specifier in WRITE statement at (1) has invalid value 'd'

---

$ cat y_test_char_4.f90
program p
   write (1, asynchronous=char(257))
end

$ gfortran y_test_char_4.f90
y_test_char_4.f90:2:26:

    write (1, asynchronous=char(257))
                          1
Error: ASYNCHRONOUS= specifier at (1) must be an initialization expression


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug fortran/66725] Issue with silent conversion int to char, ICE if int too large
  2015-07-01 16:28 [Bug fortran/66725] New: Issue with silent conversion int to char, struggling in gfc_widechar_to_char gerhard.steinmetz.fortran@t-online.de
  2015-07-01 16:30 ` [Bug fortran/66725] " gerhard.steinmetz.fortran@t-online.de
@ 2015-07-02 21:40 ` kargl at gcc dot gnu.org
  2015-07-04 15:37 ` kargl at gcc dot gnu.org
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: kargl at gcc dot gnu.org @ 2015-07-02 21:40 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66725

kargl at gcc dot gnu.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P3                          |P4
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2015-07-02
                 CC|                            |kargl at gcc dot gnu.org
           Assignee|unassigned at gcc dot gnu.org      |kargl at gcc dot gnu.org
     Ever confirmed|0                           |1

--- Comment #3 from kargl at gcc dot gnu.org ---
It seems that a type check is missing for STATUS=some_entity.
With this diff (watch cut-n-paste tab corruption),

Index: io.c
===================================================================
--- io.c        (revision 225348)
+++ io.c        (working copy)
@@ -2071,6 +2071,12 @@ gfc_match_open (void)
       static const char *status[] = { "OLD", "NEW", "SCRATCH",
        "REPLACE", "UNKNOWN", NULL };

+      if (open->status->ts.type != BT_CHARACTER)
+       {
+         gfc_error("scalar-default-char-expr required at %C");
+         goto cleanup;
+       } 
+
       if (!compare_to_allowed_values ("STATUS", status, NULL, NULL,
                                      open->status->value.character.string,
                                      "OPEN", warn))

I get

% gfc6 -o z aa.f90
aa.f90:2:23:

    open (1, status=257)
                       1
Error: scalar-default-char-expr required at (1)

I suspect the other TAGS need a similar check.


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug fortran/66725] Issue with silent conversion int to char, ICE if int too large
  2015-07-01 16:28 [Bug fortran/66725] New: Issue with silent conversion int to char, struggling in gfc_widechar_to_char gerhard.steinmetz.fortran@t-online.de
  2015-07-01 16:30 ` [Bug fortran/66725] " gerhard.steinmetz.fortran@t-online.de
  2015-07-02 21:40 ` [Bug fortran/66725] Issue with silent conversion int to char, ICE if int too large kargl at gcc dot gnu.org
@ 2015-07-04 15:37 ` kargl at gcc dot gnu.org
  2015-07-04 15:40 ` kargl at gcc dot gnu.org
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: kargl at gcc dot gnu.org @ 2015-07-04 15:37 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66725

--- Comment #4 from kargl at gcc dot gnu.org ---
Author: kargl
Date: Sat Jul  4 15:37:04 2015
New Revision: 225415

URL: https://gcc.gnu.org/viewcvs?rev=225415&root=gcc&view=rev
Log:
2015-07-04  Steven G. Kargl  <kargl@gcc.gnu.org>

        PR fortran/66725
        * io.c (is_char_type): New function to test for BT_CHARACTER
        (gfc_match_open, gfc_match_close, match_dt_element): Use it.


2015-07-03  Steven G. Kargl  <kargl@gcc.gnu.org>

        PR fortran/66725
        * gfortran.dg/pr66725.f90: New test.

Added:
    trunk/gcc/testsuite/gfortran.dg/pr66725.f90
Modified:
    trunk/gcc/fortran/ChangeLog
    trunk/gcc/fortran/io.c
    trunk/gcc/testsuite/ChangeLog


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug fortran/66725] Issue with silent conversion int to char, ICE if int too large
  2015-07-01 16:28 [Bug fortran/66725] New: Issue with silent conversion int to char, struggling in gfc_widechar_to_char gerhard.steinmetz.fortran@t-online.de
                   ` (2 preceding siblings ...)
  2015-07-04 15:37 ` kargl at gcc dot gnu.org
@ 2015-07-04 15:40 ` kargl at gcc dot gnu.org
  2015-07-16 18:21 ` kargl at gcc dot gnu.org
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: kargl at gcc dot gnu.org @ 2015-07-04 15:40 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66725

--- Comment #5 from kargl at gcc dot gnu.org ---
Patch posted here.

https://gcc.gnu.org/ml/gcc-patches/2015-07/msg00235.html


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug fortran/66725] Issue with silent conversion int to char, ICE if int too large
  2015-07-01 16:28 [Bug fortran/66725] New: Issue with silent conversion int to char, struggling in gfc_widechar_to_char gerhard.steinmetz.fortran@t-online.de
                   ` (3 preceding siblings ...)
  2015-07-04 15:40 ` kargl at gcc dot gnu.org
@ 2015-07-16 18:21 ` kargl at gcc dot gnu.org
  2015-07-16 19:06 ` kargl at gcc dot gnu.org
  2015-07-17  0:32 ` kargl at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: kargl at gcc dot gnu.org @ 2015-07-16 18:21 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66725

--- Comment #6 from kargl at gcc dot gnu.org ---
Author: kargl
Date: Thu Jul 16 18:21:22 2015
New Revision: 225898

URL: https://gcc.gnu.org/viewcvs?rev=225898&root=gcc&view=rev
Log:
2015-07-03  Steven G. Kargl  <kargl@gcc.gnu.org>

        PR fortran/66725
        * io.c (is_char_type): New function to test for BT_CHARACTER
        (gfc_match_open, gfc_match_close, match_dt_element): Use it.


2015-07-03  Steven G. Kargl  <kargl@gcc.gnu.org>

        PR fortran/66725
        * gfortran.dg/pr66725.f90: New test.


Added:
    branches/gcc-5-branch/gcc/testsuite/gfortran.dg/pr66725.f90
Modified:
    branches/gcc-5-branch/gcc/fortran/ChangeLog
    branches/gcc-5-branch/gcc/fortran/io.c
    branches/gcc-5-branch/gcc/testsuite/ChangeLog


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug fortran/66725] Issue with silent conversion int to char, ICE if int too large
  2015-07-01 16:28 [Bug fortran/66725] New: Issue with silent conversion int to char, struggling in gfc_widechar_to_char gerhard.steinmetz.fortran@t-online.de
                   ` (4 preceding siblings ...)
  2015-07-16 18:21 ` kargl at gcc dot gnu.org
@ 2015-07-16 19:06 ` kargl at gcc dot gnu.org
  2015-07-17  0:32 ` kargl at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: kargl at gcc dot gnu.org @ 2015-07-16 19:06 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66725

kargl at gcc dot gnu.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|---                         |FIXED
   Target Milestone|---                         |5.3

--- Comment #7 from kargl at gcc dot gnu.org ---
Fixed on trunk and 5-branch.  Thanks for the bug report.


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug fortran/66725] Issue with silent conversion int to char, ICE if int too large
  2015-07-01 16:28 [Bug fortran/66725] New: Issue with silent conversion int to char, struggling in gfc_widechar_to_char gerhard.steinmetz.fortran@t-online.de
                   ` (5 preceding siblings ...)
  2015-07-16 19:06 ` kargl at gcc dot gnu.org
@ 2015-07-17  0:32 ` kargl at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: kargl at gcc dot gnu.org @ 2015-07-17  0:32 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66725

--- Comment #8 from kargl at gcc dot gnu.org ---
Author: kargl
Date: Fri Jul 17 00:31:45 2015
New Revision: 225917

URL: https://gcc.gnu.org/viewcvs?rev=225917&root=gcc&view=rev
Log:
2015-07-16  Steven G. Kargl  <kargl@gcc.gnu.org>

        PR fortran/66724
        PR fortran/66725
        * io.c (is_char_type): Call gfc_resolve_expr().
        (match_open_element, match_dt_element, match_inquire_element): Fix
        ASYNCHRONOUS case.


Modified:
    branches/gcc-5-branch/gcc/fortran/ChangeLog
    branches/gcc-5-branch/gcc/fortran/io.c


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2015-07-17  0:32 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-07-01 16:28 [Bug fortran/66725] New: Issue with silent conversion int to char, struggling in gfc_widechar_to_char gerhard.steinmetz.fortran@t-online.de
2015-07-01 16:30 ` [Bug fortran/66725] " gerhard.steinmetz.fortran@t-online.de
2015-07-02 21:40 ` [Bug fortran/66725] Issue with silent conversion int to char, ICE if int too large kargl at gcc dot gnu.org
2015-07-04 15:37 ` kargl at gcc dot gnu.org
2015-07-04 15:40 ` kargl at gcc dot gnu.org
2015-07-16 18:21 ` kargl at gcc dot gnu.org
2015-07-16 19:06 ` kargl at gcc dot gnu.org
2015-07-17  0:32 ` kargl 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).