Bug 26822 - Scalarization of non-elemental intrinsic: __logical_4_l4
Summary: Scalarization of non-elemental intrinsic: __logical_4_l4
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: fortran (show other bugs)
Version: 4.2.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-03-23 09:25 UTC by Carsten Lemmen
Modified: 2006-04-23 05:37 UTC (History)
3 users (show)

See Also:
Host: i686-pc-linux-gnu
Target: i686-pc-linux-gnu
Build: i686-pc-linux-gnu
Known to work:
Known to fail:
Last reconfirmed: 2006-03-24 13:27:46


Attachments
Reduced Testcase that produces the failure (324 bytes, text/plain)
2006-03-24 08:30 UTC, Carsten Lemmen
Details
Patch to fix P26822 (284 bytes, patch)
2006-04-13 13:04 UTC, Paul Thomas
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Carsten Lemmen 2006-03-23 09:25:18 UTC
While PR 17298 fixed part of the OP to PR17298, for logical transfer statements the problem persists with  4.2.0 20060323

----------------------------------------------------

./numrec-f90> gfortran -v -c src/bessj.f90
Es werden eingebaute Spezifikationen verwendet.
Ziel: i686-pc-linux-gnu
Konfiguriert mit: /opt/src/gcc/configure --prefix=/opt --enable-languages=c,c++,fortran --enable-checking --enable-cxa_atexit
Thread-Modell: posix
gcc-Version 4.2.0 20060323 (experimental)
/opt/libexec/gcc/i686-pc-linux-gnu/4.2.0/f951 src/bessj.f90 -quiet -dumpbase bessj.f90 -mtune=generic -auxbase bessj -version -I /opt/lib/gcc/i686-pc-linux-gnu/4.2.0/finclude -o /tmp/ccQU67R0.s
GNU F95 Version 4.2.0 20060323 (experimental) (i686-pc-linux-gnu)
        kompiliert von GNU-C-Version 4.2.0 20060323 (experimental).
GGC-Heuristik: --param ggc-min-expand=30 --param ggc-min-heapsize=4096
src/bessj.f90: In Funktion »bessj_v«:
src/bessj.f90:69: schwerwiegender Fehler: gfc_todo: Not Implemented: Scalarization of non-elemental intrinsic: __logical_4_l4
Kompilierung beendet.
Comment 1 Carsten Lemmen 2006-03-23 09:27:47 UTC
Last bug preventing the successful compilation of numerical recipes with gfortran
Comment 2 Paul Thomas 2006-03-23 16:53:02 UTC
Subject: Re:   New: Scalarization of non-elemental intrinsic:
 __logical_4_l4

Carsten,

Would you be so kind as to send me bessj.f90, please?  My Numerical 
Recipes is the F77 version!

I am not sure that I know how this message is being generated!  With GNU 
Fortran 95 (GCC) 4.2.0 20060322 (experimental)

  logical(4)  :: l(4), ls
  integer(4)  :: i(4), is

  l = (/.TRUE., .FALSE., .TRUE., .FALSE./)
  print *, transfer (l, i, 2)

  ls = .TRUE.
  print *, transfer (ls, i)

  is = ls
  print *, is

  i = l
  print *, i
end

Gives

 In file pr26822.f90:10

  is = ls
      1
Warning: Extension: Conversion from LOGICAL(4) to INTEGER(4) at (1)
 In file pr26822.f90:13

  i = l
     1
Warning: Extension: Conversion from LOGICAL(4) to INTEGER(4) at (1)

but runs correctly.

Thanks

Paul

>While PR 17298 fixed part of the OP to PR17298, for logical transfer statements
>the problem persists with  4.2.0 20060323
>
>----------------------------------------------------
>
>./numrec-f90> gfortran -v -c src/bessj.f90
>Es werden eingebaute Spezifikationen verwendet.
>Ziel: i686-pc-linux-gnu
>Konfiguriert mit: /opt/src/gcc/configure --prefix=/opt
>--enable-languages=c,c++,fortran --enable-checking --enable-cxa_atexit
>Thread-Modell: posix
>gcc-Version 4.2.0 20060323 (experimental)
>/opt/libexec/gcc/i686-pc-linux-gnu/4.2.0/f951 src/bessj.f90 -quiet -dumpbase
>bessj.f90 -mtune=generic -auxbase bessj -version -I
>/opt/lib/gcc/i686-pc-linux-gnu/4.2.0/finclude -o /tmp/ccQU67R0.s
>GNU F95 Version 4.2.0 20060323 (experimental) (i686-pc-linux-gnu)
>        kompiliert von GNU-C-Version 4.2.0 20060323 (experimental).
>GGC-Heuristik: --param ggc-min-expand=30 --param ggc-min-heapsize=4096
>src/bessj.f90: In Funktion »bessj_v«:
>src/bessj.f90:69: schwerwiegender Fehler: gfc_todo: Not Implemented:
>Scalarization of non-elemental intrinsic: __logical_4_l4
>Kompilierung beendet.
>
>
>


Comment 3 Carsten Lemmen 2006-03-24 08:30:29 UTC
Created attachment 11110 [details]
Reduced Testcase that produces the failure

Testcase attached
Comment 4 Andrew Pinski 2006-03-24 13:27:46 UTC
Confirmed.
Comment 5 Thomas Koenig 2006-03-25 22:01:44 UTC
Reduced test case:

program main
  logical, dimension(2) :: mask1, mask2
  mask2 = logical(mask1)
end program main

Unless I miss something, the logical is a no-op.
Comment 6 Paul Thomas 2006-04-13 13:04:27 UTC
Created attachment 11256 [details]
Patch to fix P26822

This took a depressingly long time to get to the bottom of - particularly since the patch changes one character!  Fortunately, it was a few minutes here and there.

The problem came about because LOGICAL was not marked as elemental in intrinsic.c(add_functions), which put it in the wrong place in trans_intrinsic.c and caused the observed consequences.

I will regtest and submit tonight but I am sure that this is the right fix.

Paul
Comment 7 patchapp@dberlin.org 2006-04-13 18:55:14 UTC
Subject: Bug number PR26822

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-04/msg00505.html
Comment 8 Paul Thomas 2006-04-16 03:45:34 UTC
Subject: Bug 26822

Author: pault
Date: Sun Apr 16 03:45:24 2006
New Revision: 112981

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=112981
Log:
2006-04-16  Paul Thomas  <pault@gcc.gnu.org>

	PR fortran/26822
	* intrinsic.c (add_functions): Mark LOGICAL as elemental.

	PR fortran/26787
	* expr.c (gfc_check_assign): Extend scope of error to include
	assignments to a procedure in the main program or, from a
	module or internal procedure that is not that represented by
	the lhs symbol. Use VARIABLE rather than l-value in message.

	PR fortran/27096
	* trans-array.c (gfc_trans_deferred_array): If the backend_decl
	is not a descriptor, dereference and then test and use the type.

	PR fortran/25597
	* trans-decl.c (gfc_trans_deferred_vars): Check if an array
	result, is also automatic character length.  If so, process
	the character length.

	PR fortran/18803
	PR fortran/25669
	PR fortran/26834
	* trans_intrinsic.c (gfc_walk_intrinsic_bound): Set
	data.info.dimen for bound intrinsics.
	* trans_array.c (gfc_conv_ss_startstride): Pick out LBOUND and
	UBOUND intrinsics and supply their shape information to the ss
	and the loop.

	PR fortran/27124
	* trans_expr.c (gfc_trans_function_call):  Add a new block, post,
	in to which all the argument post blocks are put.  Add this block
	to se->pre after a byref call or to se->post, otherwise.

2006-04-16  Paul Thomas  <pault@gcc.gnu.org>

	PR fortran/26787
	* gfortran.dg/proc_assign_1.f90: New test.
	* gfortran.dg/procedure_lvalue.f90: Change message.
	* gfortran.dg/namelist_4.f90: Add new error.

	PR fortran/27096
	* gfortran.dg/auto_pointer_array_result_1.f90

	PR fortran/27089
	* gfortran.dg/specification_type_resolution_1.f90

	PR fortran/18803
	PR fortran/25669
	PR fortran/26834
	* gfortran.dg/bounds_temporaries_1.f90: New test.

	PR fortran/27124
	* gfortran.dg/array_return_value_1.f90: New test.



Added:
    trunk/gcc/testsuite/gfortran.dg/array_return_value_1.f90
    trunk/gcc/testsuite/gfortran.dg/auto_char_pointer_array_result_1.f90
    trunk/gcc/testsuite/gfortran.dg/auto_pointer_array_result_1.f90
    trunk/gcc/testsuite/gfortran.dg/bounds_temporaries_1.f90
    trunk/gcc/testsuite/gfortran.dg/proc_assign_1.f90
    trunk/gcc/testsuite/gfortran.dg/specification_type_resolution_1.f90
Modified:
    trunk/gcc/fortran/ChangeLog
    trunk/gcc/fortran/expr.c
    trunk/gcc/fortran/intrinsic.c
    trunk/gcc/fortran/resolve.c
    trunk/gcc/fortran/trans-array.c
    trunk/gcc/fortran/trans-decl.c
    trunk/gcc/fortran/trans-expr.c
    trunk/gcc/fortran/trans-intrinsic.c
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/testsuite/gfortran.dg/namelist_4.f90
    trunk/gcc/testsuite/gfortran.dg/procedure_lvalue.f90

Comment 9 Paul Thomas 2006-04-23 05:33:26 UTC
Subject: Bug 26822

Author: pault
Date: Sun Apr 23 05:33:16 2006
New Revision: 113191

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=113191
Log:
2006-04-23  Paul Thomas  <pault@gcc.gnu.org>

	PR fortran/27122
	* resolve.c (resolve_function): Remove general restriction on auto
	character length function interfaces.
	(gfc_resolve_uops): Check restrictions on defined operator
	procedures.
	(resolve_types): Call the check for defined operators.

	PR fortran/27113
	* trans-array.c (get_array_ctor_var_strlen): Remove typo in enum.
	Part of the fix in 4.2, which does not work in 4.1 because the
	divergence is now too great.

	PR fortran/26822
	* intrinsic.c (add_functions): Mark LOGICAL as elemental.

	PR fortran/26787
	* expr.c (gfc_check_assign): Extend scope of error to include
	assignments to a procedure in the main program or, from a
	module or internal procedure that is not that represented by
	the lhs symbol. Use VARIABLE rather than l-value in message.

	PR fortran/25597
	* trans-decl.c (gfc_trans_deferred_vars): Check if an array
	result, is also automatic character length.  If so, process
	the character length. Note that this fixes the bug in 4.2
	but not here in 4.1 because the trees have diverged too much.
	Manifestly correct, so applied anyway.

	PR fortran/18803
	PR fortran/25669
	PR fortran/26834
	* trans_intrinsic.c (gfc_walk_intrinsic_bound): Set
	data.info.dimen for bound intrinsics.
	* trans_array.c (gfc_conv_ss_startstride): Pick out LBOUND and
	UBOUND intrinsics and supply their shape information to the ss
	and the loop.

	PR fortran/27124
	* trans_expr.c (gfc_trans_function_call):  Add a new block, post,
	in to which all the argument post blocks are put.  Add this block
	to se->pre after a byref call or to se->post, otherwise.

2006-04-23  Paul Thomas  <pault@gcc.gnu.org>

	PR fortran/27122
	* gfortran.dg/defined_operators_1.f90: New test.
	* gfortran.dg/assumed_charlen_function_1.f90: Add new error and
	remove old ones associated, incorrectly, with Note 5.46.

	PR fortran/26787
	* gfortran.dg/proc_assign_1.f90: New test.
	* gfortran.dg/procedure_lvalue.f90: Change message.
	* gfortran.dg/namelist_4.f90: Add new error.

	PR fortran/27089
	* gfortran.dg/specification_type_resolution_1.f90

	PR fortran/18803
	PR fortran/25669
	PR fortran/26834
	* gfortran.dg/bounds_temporaries_1.f90: New test.

	PR fortran/27124
	* gfortran.dg/array_return_value_1.f90: New test.



Added:
    branches/gcc-4_1-branch/gcc/testsuite/gfortran.dg/array_return_value_1.f90
    branches/gcc-4_1-branch/gcc/testsuite/gfortran.dg/bounds_temporaries_1.f90
    branches/gcc-4_1-branch/gcc/testsuite/gfortran.dg/defined_operators_1.f90
    branches/gcc-4_1-branch/gcc/testsuite/gfortran.dg/proc_assign_1.f90
    branches/gcc-4_1-branch/gcc/testsuite/gfortran.dg/specification_type_resolution_1.f90
Modified:
    branches/gcc-4_1-branch/gcc/fortran/ChangeLog
    branches/gcc-4_1-branch/gcc/fortran/expr.c
    branches/gcc-4_1-branch/gcc/fortran/intrinsic.c
    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-decl.c
    branches/gcc-4_1-branch/gcc/fortran/trans-expr.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/assumed_charlen_function_1.f90
    branches/gcc-4_1-branch/gcc/testsuite/gfortran.dg/namelist_4.f90
    branches/gcc-4_1-branch/gcc/testsuite/gfortran.dg/procedure_lvalue.f90

Comment 10 Paul Thomas 2006-04-23 05:37:20 UTC
Fixed on trunk and 4.1

Paul