public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/31304] REPEAT argument NCOPIES is not converted as it should
  2007-03-21 23:55 [Bug fortran/31304] New: REPEAT argument NCOPIES is not converted as it should fxcoudert at gcc dot gnu dot org
@ 2007-03-21 23:55 ` fxcoudert at gcc dot gnu dot org
  2007-03-30 10:00 ` fxcoudert at gcc dot gnu dot org
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: fxcoudert at gcc dot gnu dot org @ 2007-03-21 23:55 UTC (permalink / raw)
  To: gcc-bugs



-- 

fxcoudert at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|0                           |1
      Known to fail|                            |4.1.3 4.2.0 4.3.0
   Last reconfirmed|0000-00-00 00:00:00         |2007-03-21 23:55:36
               date|                            |


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31304


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

* [Bug fortran/31304]  New: REPEAT argument NCOPIES is not converted as it should
@ 2007-03-21 23:55 fxcoudert at gcc dot gnu dot org
  2007-03-21 23:55 ` [Bug fortran/31304] " fxcoudert at gcc dot gnu dot org
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: fxcoudert at gcc dot gnu dot org @ 2007-03-21 23:55 UTC (permalink / raw)
  To: gcc-bugs

The NCOPIES argument of REPEAT is not converted to the integer king the library
expects (kind=4), which can lead to segfaults. I changed that code recently, so
I'll fix it. I'll probably take this opportunity to have the front-end actually
emit an error if the NCOPIES argument is larger than a fixed value.

$ cat repeat.f90
   implicit none

   integer(kind=1) i
   real(kind=8) r
   character(len=2) s1, s2

   i = 1
   r = 1
   s1 = '42'
   r = nearest(r,r)
   s2 = repeat(s1,i)
end
$ gfortran repeat.f90 && ./a.out
Segmentation fault


-- 
           Summary: REPEAT argument NCOPIES is not converted as it should
           Product: gcc
           Version: 4.3.0
            Status: UNCONFIRMED
          Keywords: ice-on-valid-code
          Severity: normal
          Priority: P3
         Component: fortran
        AssignedTo: fxcoudert at gcc dot gnu dot org
        ReportedBy: fxcoudert at gcc dot gnu dot org


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31304


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

* [Bug fortran/31304] REPEAT argument NCOPIES is not converted as it should
  2007-03-21 23:55 [Bug fortran/31304] New: REPEAT argument NCOPIES is not converted as it should fxcoudert at gcc dot gnu dot org
  2007-03-21 23:55 ` [Bug fortran/31304] " fxcoudert at gcc dot gnu dot org
@ 2007-03-30 10:00 ` fxcoudert at gcc dot gnu dot org
  2007-03-31 11:29 ` fxcoudert at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: fxcoudert at gcc dot gnu dot org @ 2007-03-30 10:00 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from fxcoudert at gcc dot gnu dot org  2007-03-30 11:00 -------
We should also diagnostic better the cases of negative of too large NCOPIES
argument, for both parameters (in simplification routine) and non-parameters.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31304


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

* [Bug fortran/31304] REPEAT argument NCOPIES is not converted as it should
  2007-03-21 23:55 [Bug fortran/31304] New: REPEAT argument NCOPIES is not converted as it should fxcoudert at gcc dot gnu dot org
  2007-03-21 23:55 ` [Bug fortran/31304] " fxcoudert at gcc dot gnu dot org
  2007-03-30 10:00 ` fxcoudert at gcc dot gnu dot org
@ 2007-03-31 11:29 ` fxcoudert at gcc dot gnu dot org
  2007-04-03 21:05 ` fxcoudert at gcc dot gnu dot org
  2007-04-03 21:07 ` fxcoudert at gcc dot gnu dot org
  4 siblings, 0 replies; 6+ messages in thread
From: fxcoudert at gcc dot gnu dot org @ 2007-03-31 11:29 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from fxcoudert at gcc dot gnu dot org  2007-03-31 12:29 -------
Created an attachment (id=13307)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=13307&action=view)
Patch that fixes the PR and a few related issues

This patch fixes both the simplification routine and the code generation. It
removes the need for the libgfortran string_repeat function by emitting inline
calls to memmove(), which probably allows greater optimization.

I added checking on too large values of the NCOPIES argument: NCOPIES has to be
such that the destination length fits in the character length integer kind
(which is for now hardcoded as kind=4, but I hope we can change that someday).


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31304


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

* [Bug fortran/31304] REPEAT argument NCOPIES is not converted as it should
  2007-03-21 23:55 [Bug fortran/31304] New: REPEAT argument NCOPIES is not converted as it should fxcoudert at gcc dot gnu dot org
                   ` (2 preceding siblings ...)
  2007-03-31 11:29 ` fxcoudert at gcc dot gnu dot org
@ 2007-04-03 21:05 ` fxcoudert at gcc dot gnu dot org
  2007-04-03 21:07 ` fxcoudert at gcc dot gnu dot org
  4 siblings, 0 replies; 6+ messages in thread
From: fxcoudert at gcc dot gnu dot org @ 2007-04-03 21:05 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from fxcoudert at gcc dot gnu dot org  2007-04-03 22:05 -------
Subject: Bug 31304

Author: fxcoudert
Date: Tue Apr  3 22:05:14 2007
New Revision: 123481

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=123481
Log:
        PR fortran/31304

        * fortran/gfortran.h (gfc_charlen_int_kind): New prototype.
        * fortran/trans-types.c (gfc_charlen_int_kind): New variable.
        (gfc_init_types): Define gfc_charlen_int_kind. 
        * fortran/trans.h (gfor_fndecl_string_repeat): Remove prototype.
        * fortran/trans-decl.c (gfor_fndecl_string_repeat): Delete.
        (gfc_build_intrinsic_function_decls): Don't set
        gfor_fndecl_string_repeat.
        * fortran/trans-intrinsic.c (gfc_conv_intrinsic_repeat): Rewrite
        so that we don't have to call a library function.
        * fortran/simplify.c (gfc_simplify_repeat): Perform the necessary
        checks on the NCOPIES argument, and work with arbitrary size
        arguments.

        * intrinsics/string_intrinsics.c (string_repeat): Remove.

        * gfortran.dg/repeat_2.f90: New test.
        * gfortran.dg/repeat_3.f90: New test.
        * gfortran.dg/repeat_4.f90: New test.

Added:
    trunk/gcc/testsuite/gfortran.dg/repeat_2.f90
    trunk/gcc/testsuite/gfortran.dg/repeat_3.f90
    trunk/gcc/testsuite/gfortran.dg/repeat_4.f90
Modified:
    trunk/gcc/fortran/ChangeLog
    trunk/gcc/fortran/gfortran.h
    trunk/gcc/fortran/simplify.c
    trunk/gcc/fortran/trans-decl.c
    trunk/gcc/fortran/trans-intrinsic.c
    trunk/gcc/fortran/trans-types.c
    trunk/gcc/fortran/trans.h
    trunk/gcc/testsuite/ChangeLog
    trunk/libgfortran/ChangeLog
    trunk/libgfortran/intrinsics/string_intrinsics.c


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31304


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

* [Bug fortran/31304] REPEAT argument NCOPIES is not converted as it should
  2007-03-21 23:55 [Bug fortran/31304] New: REPEAT argument NCOPIES is not converted as it should fxcoudert at gcc dot gnu dot org
                   ` (3 preceding siblings ...)
  2007-04-03 21:05 ` fxcoudert at gcc dot gnu dot org
@ 2007-04-03 21:07 ` fxcoudert at gcc dot gnu dot org
  4 siblings, 0 replies; 6+ messages in thread
From: fxcoudert at gcc dot gnu dot org @ 2007-04-03 21:07 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from fxcoudert at gcc dot gnu dot org  2007-04-03 22:07 -------
Fixed on mainline, closing.


-- 

fxcoudert at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
      Known to fail|4.1.3 4.2.0 4.3.0           |4.2.0 4.1.3
      Known to work|                            |4.3.0
         Resolution|                            |FIXED
   Target Milestone|---                         |4.3.0


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31304


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

end of thread, other threads:[~2007-04-03 21:07 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-03-21 23:55 [Bug fortran/31304] New: REPEAT argument NCOPIES is not converted as it should fxcoudert at gcc dot gnu dot org
2007-03-21 23:55 ` [Bug fortran/31304] " fxcoudert at gcc dot gnu dot org
2007-03-30 10:00 ` fxcoudert at gcc dot gnu dot org
2007-03-31 11:29 ` fxcoudert at gcc dot gnu dot org
2007-04-03 21:05 ` fxcoudert at gcc dot gnu dot org
2007-04-03 21:07 ` fxcoudert at gcc dot gnu dot 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).