Bug 36590 - internal error: Can't convert LOGICAL(1) to LOGICAL(1)
Summary: internal error: Can't convert LOGICAL(1) to LOGICAL(1)
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: fortran (show other bugs)
Version: 4.4.0
: P3 normal
Target Milestone: ---
Assignee: Thomas Koenig
URL:
Keywords: ice-on-valid-code
Depends on:
Blocks:
 
Reported: 2008-06-21 16:21 UTC by Norman S. Clerman
Modified: 2008-07-02 14:40 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2008-07-02 12:34:20


Attachments
bug3.tgz (189.53 KB, application/x-compressed-tar)
2008-06-21 16:28 UTC, Norman S. Clerman
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Norman S. Clerman 2008-06-21 16:21:14 UTC
Hello,

  The build of my program terminates on file mtfcontrolargsM.f90, and I see the following message:

mtfcontrolargsM.f90:805.25:

end module MTFControlArgs
                        1
Internal Error at (1):
mtfcontrolargsM.f90:631.32:

      This % NLam = count (.not. Near0 (This % PolyMTFWeight(1: NO_MTF_WAVES)))
                               1
Can't convert LOGICAL(1) to LOGICAL(1) at (1)

As soon as I am assigned a bug number, I will upload a tar file, bug3.tgz to the following address: gcc-bugzilla@gcc.gnu.org. Unpack the file and invoke the shell script bug3.sh to reproduce the problem.

I'll indicate the bug number in the subject line.

I am running Open SuSE 10.1 on a dual core Athlon chip. I'm using the gcc-trunk build:

norm@oxford:~/design/gfortran/bug3/test> gfortran --version
GNU Fortran (GCC) 4.4.0 20080621 (experimental) [trunk revision 137000]
Copyright (C) 2008 Free Software Foundation, Inc.

I am not able to reduce the size of the problem.

Yours truly,

Norm Clerman
Comment 1 Norman S. Clerman 2008-06-21 16:28:03 UTC
Subject: gfortran bug 36590

Hello,

  Attached is the zipped tar archive that will enable you to reproduce gfortran bug 36590.

  Unpack the archive in a directory and then invoke file bug3.sh to reproduce it. If there are any problems or questions, do not hesitate to send me an e-mail

  Thank you for your attention.

Norm Clerman
Comment 2 Norman S. Clerman 2008-06-21 16:28:03 UTC
Created attachment 15799 [details]
bug3.tgz
Comment 3 Jerry DeLisle 2008-06-21 19:26:56 UTC
I have not confirmed this but its not a "blocker".  Next step will be to see if someone can reduce this.
Comment 4 Tobias Burnus 2008-06-21 20:16:58 UTC
CONFIRM. Reduced test case:

MODULE MTFControlArgs
  TYPE, PUBLIC :: TMTFControlArgs
    Real(8) :: PolyMTFWeight (1:10)
  end type TMTFControlArgs

  interface Near0
    elemental function Near0_dp (TestNumber) result (NumberNear0)
      real (8), intent(in) :: TestNumber
      logical (1) :: NumberNear0
    end function Near0_dp
    elemental function Near0_sp (TestNumber) result (NumberNear0)
      real (4), intent(in) :: TestNumber
      logical (1) :: NumberNear0
    end function Near0_sp
  end interface
contains
  subroutine getSpc_MTFCA (This)
    type (TMTFControlArgs), intent(inout) :: This
    integer(1) :: i
    i = count (.not. Near0 (This % PolyMTFWeight(1: 10)))
  end subroutine GetSpc_MTFCA
end module MTFControlArgs
Comment 5 Tobias Burnus 2008-06-22 12:28:20 UTC
The error only occurs for logical(1), kind=2,4,8,16 all work.
The program also works if one removes the .not.

  interface Near0
    function Near0_dp (TestNumber) result (NumberNear0)
      real       :: TestNumber(2)
      logical(1) :: NumberNear0(2)
    end function Near0_dp
  end interface
  real :: PolyMTFWeight(2)
  i = count (.not. Near0 (PolyMTFWeight(1:2)))
end
Comment 6 Tobias Burnus 2008-06-22 16:26:14 UTC
Patch. The problem was that gfortran failed to find a conversion routine for logical(1) to logical(1), now it simply does nothing and reports success.

I'm not sure whether BT_VOID needs some special care or not. (Cf. interface.c's gfc_compare_types. Probably BT_VOID can never happen - or can it?)

Index: intrinsic.c
===================================================================
--- intrinsic.c (Revision 137011)
+++ intrinsic.c
@@ -3701,8 +3701,7 @@ gfc_convert_type_warn (gfc_expr *expr, g
   if (expr->ts.type == BT_UNKNOWN)
     goto bad;

-  if (expr->ts.type == BT_DERIVED && ts->type == BT_DERIVED
-      && gfc_compare_types (&expr->ts, ts))
+  if (gfc_compare_types (&expr->ts, ts))
     return SUCCESS;

   sym = find_conv (&expr->ts, ts);
Comment 7 Thomas Koenig 2008-07-02 14:38:12 UTC
Subject: Bug 36590

Author: tkoenig
Date: Wed Jul  2 14:36:58 2008
New Revision: 137355

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=137355
Log:
2008-07-02  Thomas Koenig  <tkoenig@gcc.gnu.org>

	PR fortran/36590
	PR fortran/36681
	* iresolve.c (resolve_mask_arg):  Don't convert mask to
	kind=1 logical if it is of that type already.

2008-07-02  Thomas Koenig  <tkoenig@gcc.gnu.org>

	PR fortran/36590
	PR fortran/36681
	* gfortran.dg/count_mask_1.f90:  New test.


Added:
    trunk/gcc/testsuite/gfortran.dg/count_mask_1.f90
Modified:
    trunk/gcc/fortran/ChangeLog
    trunk/gcc/fortran/iresolve.c
    trunk/gcc/testsuite/ChangeLog

Comment 8 Thomas Koenig 2008-07-02 14:40:41 UTC
Fixed.  Closing.