public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/28094]  New: Modulo of real(kind=10) variables doesn't work
@ 2006-06-20 11:57 fxcoudert at gcc dot gnu dot org
  2006-06-20 19:09 ` [Bug fortran/28094] " paulthomas2 at wanadoo dot fr
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: fxcoudert at gcc dot gnu dot org @ 2006-06-20 11:57 UTC (permalink / raw)
  To: gcc-bugs

While working on PR 24518, I found the following:

$ cat a.f90 
  real(kind=10) :: x = 10.0
  print *, mod (x,x)
  end
$ gfortran a.f90
 In file a.f90:3

  end
    1
 Internal Error at (1):
 gfc_validate_kind(): Got bad kind


It looks like we're trying to use the integer kind associated with the real
kind, and of course, there's not integer(kind=10) available.


-- 
           Summary: Modulo of real(kind=10) variables doesn't work
           Product: gcc
           Version: 4.2.0
            Status: UNCONFIRMED
          Keywords: ice-on-valid-code
          Severity: normal
          Priority: P3
         Component: fortran
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: fxcoudert at gcc dot gnu dot org


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


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

* [Bug fortran/28094] Modulo of real(kind=10) variables doesn't work
  2006-06-20 11:57 [Bug fortran/28094] New: Modulo of real(kind=10) variables doesn't work fxcoudert at gcc dot gnu dot org
@ 2006-06-20 19:09 ` paulthomas2 at wanadoo dot fr
  2006-06-21 14:54 ` fxcoudert at gcc dot gnu dot org
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: paulthomas2 at wanadoo dot fr @ 2006-06-20 19:09 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from paulthomas2 at wanadoo dot fr  2006-06-20 19:08 -------
Subject: Re:   New: Modulo of real(kind=10) variables doesn't
 work

fxcoudert at gcc dot gnu dot org wrote:

>While working on PR 24518, I found the following:
>
>$ cat a.f90 
>  real(kind=10) :: x = 10.0
>  print *, mod (x,x)
>  end
>$ gfortran a.f90
> In file a.f90:3
>
>  end
>    1
> Internal Error at (1):
> gfc_validate_kind(): Got bad kind
>
>
>It looks like we're trying to use the integer kind associated with the real
>kind, and of course, there's not integer(kind=10) available.
>  
>
Yes, I knew about this and assumed that it was all part of Cygwin being 
Hicksville!

Seriously, I never got round to reporting it because I was so tied up 
trying to prepare a decent fix for mod.

Paul


-- 


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


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

* [Bug fortran/28094] Modulo of real(kind=10) variables doesn't work
  2006-06-20 11:57 [Bug fortran/28094] New: Modulo of real(kind=10) variables doesn't work fxcoudert at gcc dot gnu dot org
  2006-06-20 19:09 ` [Bug fortran/28094] " paulthomas2 at wanadoo dot fr
@ 2006-06-21 14:54 ` fxcoudert at gcc dot gnu dot org
  2006-06-24  8:36 ` fxcoudert at gcc dot gnu dot org
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: fxcoudert at gcc dot gnu dot org @ 2006-06-21 14:54 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from fxcoudert at gcc dot gnu dot org  2006-06-21 14:49 -------
This "modulo" code is not very clear in my head. I'm not sure why this
implementation (using an integer kind *equal* to the real kind) is supposed to
be working. Anyway, without changing the current implentation, this bug can be
fixed by the following patch:

Index: trans-intrinsic.c
===================================================================
--- trans-intrinsic.c   (revision 114791)
+++ trans-intrinsic.c   (working copy)
@@ -860,7 +860,7 @@
   tree test;
   tree test2;
   mpfr_t huge;
-  int n;
+  int n, ikind;

   arg = gfc_conv_intrinsic_function_args (se, expr);
   arg2 = TREE_VALUE (TREE_CHAIN (arg));
@@ -886,7 +886,13 @@
       /* Test if the value is too large to handle sensibly.  */
       gfc_set_model_kind (expr->ts.kind);
       mpfr_init (huge);
-      n = gfc_validate_kind (BT_INTEGER, expr->ts.kind, false);
+      n = gfc_validate_kind (BT_INTEGER, expr->ts.kind, true);
+      ikind = expr->ts.kind;
+      if (n < 0)
+       {
+         n = gfc_validate_kind (BT_INTEGER, gfc_max_integer_kind, false);
+         ikind = gfc_max_integer_kind;
+       }
       mpfr_set_z (huge, gfc_integer_kinds[n].huge, GFC_RND_MODE);
       test = gfc_conv_mpfr_to_tree (huge, expr->ts.kind);
       test2 = build2 (LT_EXPR, boolean_type_node, tmp, test);
@@ -896,7 +902,7 @@
       test = build2 (GT_EXPR, boolean_type_node, tmp, test);
       test2 = build2 (TRUTH_AND_EXPR, boolean_type_node, test, test2);

-      itype = gfc_get_int_type (expr->ts.kind);
+      itype = gfc_get_int_type (ikind);
       if (modulo)
        tmp = build_fix_expr (&se->pre, tmp, itype, FIX_FLOOR_EXPR);
       else


-- 

fxcoudert at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         AssignedTo|unassigned at gcc dot gnu   |fxcoudert at gcc dot gnu dot
                   |dot org                     |org
             Status|UNCONFIRMED                 |ASSIGNED
     Ever Confirmed|0                           |1
           Keywords|                            |patch
      Known to fail|                            |4.2.0 4.1.2
   Last reconfirmed|0000-00-00 00:00:00         |2006-06-21 14:49:58
               date|                            |


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


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

* [Bug fortran/28094] Modulo of real(kind=10) variables doesn't work
  2006-06-20 11:57 [Bug fortran/28094] New: Modulo of real(kind=10) variables doesn't work fxcoudert at gcc dot gnu dot org
  2006-06-20 19:09 ` [Bug fortran/28094] " paulthomas2 at wanadoo dot fr
  2006-06-21 14:54 ` fxcoudert at gcc dot gnu dot org
@ 2006-06-24  8:36 ` fxcoudert at gcc dot gnu dot org
  2006-06-24  9:23 ` [Bug fortran/28094] [4.1 only] " fxcoudert at gcc dot gnu dot org
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: fxcoudert at gcc dot gnu dot org @ 2006-06-24  8:36 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from fxcoudert at gcc dot gnu dot org  2006-06-24 08:27 -------
Subject: Bug 28094

Author: fxcoudert
Date: Sat Jun 24 08:27:32 2006
New Revision: 114961

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

        * trans-intrinsic.c (gfc_conv_intrinsic_mod): Support cases where
        there is no integer kind equal to the resulting real kind.
        * intrinsic.c (add_functions): MODULO is not allowed as an actual
        argument.

        * Makefile.am: Add _mod_r10.F90 and _mod_r16.F90.
        * Makefile.in: Regenerate.
        * generated/_mod_r10.F90: New file.
        * generated/_mod_r16.F90: New file.

Added:
    trunk/libgfortran/generated/_mod_r10.F90
    trunk/libgfortran/generated/_mod_r16.F90
Modified:
    trunk/gcc/fortran/ChangeLog
    trunk/gcc/fortran/intrinsic.c
    trunk/gcc/fortran/trans-intrinsic.c
    trunk/libgfortran/ChangeLog
    trunk/libgfortran/Makefile.am
    trunk/libgfortran/Makefile.in


-- 


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


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

* [Bug fortran/28094] [4.1 only] Modulo of real(kind=10) variables doesn't work
  2006-06-20 11:57 [Bug fortran/28094] New: Modulo of real(kind=10) variables doesn't work fxcoudert at gcc dot gnu dot org
                   ` (2 preceding siblings ...)
  2006-06-24  8:36 ` fxcoudert at gcc dot gnu dot org
@ 2006-06-24  9:23 ` fxcoudert at gcc dot gnu dot org
  2006-06-29 21:40 ` patchapp at dberlin dot org
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: fxcoudert at gcc dot gnu dot org @ 2006-06-24  9:23 UTC (permalink / raw)
  To: gcc-bugs



-- 

fxcoudert at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
      Known to fail|4.2.0 4.1.2                 |4.1.2
      Known to work|                            |4.2.0
            Summary|Modulo of real(kind=10)     |[4.1 only] Modulo of
                   |variables doesn't work      |real(kind=10) variables
                   |                            |doesn't work
   Target Milestone|---                         |4.1.2


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


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

* [Bug fortran/28094] [4.1 only] Modulo of real(kind=10) variables doesn't work
  2006-06-20 11:57 [Bug fortran/28094] New: Modulo of real(kind=10) variables doesn't work fxcoudert at gcc dot gnu dot org
                   ` (3 preceding siblings ...)
  2006-06-24  9:23 ` [Bug fortran/28094] [4.1 only] " fxcoudert at gcc dot gnu dot org
@ 2006-06-29 21:40 ` patchapp at dberlin dot org
  2006-07-02 21:17 ` fxcoudert at gcc dot gnu dot org
  2006-07-02 21:23 ` [Bug fortran/28094] " fxcoudert at gcc dot gnu dot org
  6 siblings, 0 replies; 8+ messages in thread
From: patchapp at dberlin dot org @ 2006-06-29 21:40 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from patchapp at dberlin dot org  2006-06-29 21:40 -------
Subject: Bug number PR fortran/28094

A patch for this bug has been added to the patch tracker.
The mailing list url for the patch is
http://gcc.gnu.org/ml/gcc-patches/2006-06/msg01183.html


-- 


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


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

* [Bug fortran/28094] [4.1 only] Modulo of real(kind=10) variables doesn't work
  2006-06-20 11:57 [Bug fortran/28094] New: Modulo of real(kind=10) variables doesn't work fxcoudert at gcc dot gnu dot org
                   ` (4 preceding siblings ...)
  2006-06-29 21:40 ` patchapp at dberlin dot org
@ 2006-07-02 21:17 ` fxcoudert at gcc dot gnu dot org
  2006-07-02 21:23 ` [Bug fortran/28094] " fxcoudert at gcc dot gnu dot org
  6 siblings, 0 replies; 8+ messages in thread
From: fxcoudert at gcc dot gnu dot org @ 2006-07-02 21:17 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #5 from fxcoudert at gcc dot gnu dot org  2006-07-02 21:17 -------
Subject: Bug 28094

Author: fxcoudert
Date: Sun Jul  2 21:17:05 2006
New Revision: 115134

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=115134
Log:
        PR fortran/28094
        * trans-intrinsic.c (gfc_conv_intrinsic_mod): Support cases where
        there is no integer kind equal to the resulting real kind.
        * intrinsic.c (add_functions): MODULO is not allowed as an actual
        argument.
        * Makefile.am: Add _mod_r10.F90 and _mod_r16.F90.
        * Makefile.in: Regenerate.
        * generated/_mod_r10.F90: New file.
        * generated/_mod_r16.F90: New file.

        PR fortran/27965
        * trans-array.c (gfc_conv_ss_startstride): Correct the runtime
        conditions for bounds-checking. Check for nonzero stride.
        Don't check the last dimension of assumed-size arrays. Fix the
        dimension displayed in the error message.

        PR fortran/26801
        * trans-intrinsic.c (gfc_conv_associated): Use pre and post blocks
        of the scalarization expression.
        * gfortran.dg/associated_4.f90: New test.

        PR fortran/28081
        * resolve.c (resolve_substring): Don't issue out-of-bounds
        error messages when the range has zero size.
        * gfortran.dg/substr_3.f: New test.
        * gfortran.dg/equiv_2.f90: Update expected error message.

        PR fortran/23862
        * lang-specs.h (f95-cpp-input): Pass -ffree-form to f951 unless
        -ffixed-form is explicitly specified.

Added:
    branches/gcc-4_1-branch/gcc/testsuite/gfortran.dg/associated_4.f90
      - copied unchanged from r114757,
trunk/gcc/testsuite/gfortran.dg/associated_4.f90
    branches/gcc-4_1-branch/gcc/testsuite/gfortran.dg/substr_3.f
      - copied unchanged from r114972,
trunk/gcc/testsuite/gfortran.dg/substr_3.f
    branches/gcc-4_1-branch/libgfortran/generated/_mod_r10.F90
      - copied unchanged from r114961, trunk/libgfortran/generated/_mod_r10.F90
    branches/gcc-4_1-branch/libgfortran/generated/_mod_r16.F90
      - copied unchanged from r114961, trunk/libgfortran/generated/_mod_r16.F90
Modified:
    branches/gcc-4_1-branch/gcc/fortran/ChangeLog
    branches/gcc-4_1-branch/gcc/fortran/intrinsic.c
    branches/gcc-4_1-branch/gcc/fortran/lang-specs.h
    branches/gcc-4_1-branch/gcc/fortran/resolve.c
    branches/gcc-4_1-branch/gcc/fortran/trans-array.c
    branches/gcc-4_1-branch/gcc/fortran/trans-intrinsic.c
    branches/gcc-4_1-branch/gcc/testsuite/ChangeLog
    branches/gcc-4_1-branch/gcc/testsuite/gfortran.dg/equiv_2.f90
    branches/gcc-4_1-branch/libgfortran/ChangeLog
    branches/gcc-4_1-branch/libgfortran/Makefile.am
    branches/gcc-4_1-branch/libgfortran/Makefile.in


-- 


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


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

* [Bug fortran/28094] Modulo of real(kind=10) variables doesn't work
  2006-06-20 11:57 [Bug fortran/28094] New: Modulo of real(kind=10) variables doesn't work fxcoudert at gcc dot gnu dot org
                   ` (5 preceding siblings ...)
  2006-07-02 21:17 ` fxcoudert at gcc dot gnu dot org
@ 2006-07-02 21:23 ` fxcoudert at gcc dot gnu dot org
  6 siblings, 0 replies; 8+ messages in thread
From: fxcoudert at gcc dot gnu dot org @ 2006-07-02 21:23 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #6 from fxcoudert at gcc dot gnu dot org  2006-07-02 21:23 -------
Fixed.


-- 

fxcoudert at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
      Known to fail|4.1.2                       |
      Known to work|4.2.0                       |4.2.0 4.1.2
         Resolution|                            |FIXED
            Summary|[4.1 only] Modulo of        |Modulo of real(kind=10)
                   |real(kind=10) variables     |variables doesn't work
                   |doesn't work                |


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


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

end of thread, other threads:[~2006-07-02 21:23 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-06-20 11:57 [Bug fortran/28094] New: Modulo of real(kind=10) variables doesn't work fxcoudert at gcc dot gnu dot org
2006-06-20 19:09 ` [Bug fortran/28094] " paulthomas2 at wanadoo dot fr
2006-06-21 14:54 ` fxcoudert at gcc dot gnu dot org
2006-06-24  8:36 ` fxcoudert at gcc dot gnu dot org
2006-06-24  9:23 ` [Bug fortran/28094] [4.1 only] " fxcoudert at gcc dot gnu dot org
2006-06-29 21:40 ` patchapp at dberlin dot org
2006-07-02 21:17 ` fxcoudert at gcc dot gnu dot org
2006-07-02 21:23 ` [Bug fortran/28094] " 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).