[Bug fortran/98454] Apparent wrong initialization in function result

2020-12-27 Thread ffadrique at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98454

--- Comment #6 from Fran Martinez Fadrique  ---
I have raised the issue with respect to 4.5.3.4 of the ISO standard that
stablishes how the type component are initialized. Not just my expectations.

I have further developed my test case and any local variable declared in any
function or subroutine in the scope of the module where the type is declared
fails to properly initialize its components according to the default
initializations (using the terminology of the standard). The intent(out) seems
to make the difference and subroutine parameters are properly initialized.
Any variable created outside the module declaring the type seems to properly
initialize the components.

I compile with -std=2018 so I would expect that invalid Fortran is flagged, at
least with a warning, which is not the case.

[Bug fortran/98454] Apparent wrong initialization in function result

2020-12-27 Thread ffadrique at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98454

--- Comment #7 from Fran Martinez Fadrique  ---
By the way, thanks for the workaround. It cleanly solves the problem, at least
temporarily.

[Bug fortran/98490] New: Unexpected out of bounds in array constructor with implied do loop

2020-12-31 Thread ffadrique at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98490

Bug ID: 98490
   Summary: Unexpected out of bounds in array constructor with
implied do loop
   Product: gcc
   Version: 9.3.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: fortran
  Assignee: unassigned at gcc dot gnu.org
  Reporter: ffadrique at gmail dot com
  Target Milestone: ---

The followinng code, when compiled with -fbounds-check produces a runtime
exception

program test

  implicit none

  call sub( 'Lorem ipsum' )

contains

subroutine sub( text )

  character(len=*), intent(in) :: text

  integer :: i

  write(*,*) [ ( text(i:i), i = 1, len(text) ) ]

end subroutine sub

end program test

Run time error:
At line 18 of file test.f90
Fortran runtime error: Substring out of bounds: lower bound (-2147483648) of
'text' is less than one

Error termination. Backtrace:
#0  0x7f01d0965d3a
#1  0x7f01d0966849
#2  0x7f01d0966ec6
#3  0x5567acbd1269
#4  0x5567acbd14e6
#5  0x5567acbd151e
#6  0x7f01d077a0b2
#7  0x5567acbd10fd
#8  0x

It is clear to me that the automatic variable i is not initialised before
invoking the implied do loop. However, the loop should run between 1 and the
length of the input text as given in the loop controls; not evaluate at the
uninitialised value.

The behaviour is as expected when not compiled with the bound check flag. Also
valgrind is not reporting any invalid memory access. The issue may be
associated to the compilation with the bound check flag (that I need to have
enabled in general). The workaround is straightforward.

I have also checked that if there were several statements like the write one in
the example, I would have to control the initial value of i before each implied
loop to make sure that the initial value is not out of the array in the loop.

  i = 1  ! Prevents the exception
  write(*,*) [ ( text1(i:i), i = 1, len(text1) ) ]  ! text1 of length 20

! Next statement triggers the exception unless i is reset again
  write(*,*) [ ( text2(i:i), i = 1, len(text2) ) ]  ! text2 of length 10

[Bug fortran/98490] Unexpected out of bounds in array constructor with implied do loop

2020-12-31 Thread ffadrique at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98490

--- Comment #2 from Fran Martinez Fadrique  ---
I am not sure to understand the question

The gfortran version is

gcc version 9.3.0 (Ubuntu 9.3.0-17ubuntu1~20.04) 

It also appear with 

gcc version 11.0.0 20201220 (experimental) (GCC)

also in Ubuntu

In case it was not clear in my initial statement, it only appears when the flag
-fbound-check is used. Otherwise the behaviour seems fine.

[Bug fortran/103957] New: ICE passing return value from elemental type bound procedure

2022-01-09 Thread ffadrique at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103957

Bug ID: 103957
   Summary: ICE passing return value from elemental type bound
procedure
   Product: gcc
   Version: 9.3.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: fortran
  Assignee: unassigned at gcc dot gnu.org
  Reporter: ffadrique at gmail dot com
  Target Milestone: ---

Created attachment 52149
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=52149&action=edit
Type used for the type bound procedure

The attached code produces an ICE when compiled with 9.3.0 (my reference
compiler)
Does not occur with 10, 11 and 12.

The problem appears on the polymorphic array (elements) but not in the array
declared with type and fixed length. If the array is allocatable but not
polymorphic the issue does not occur either.


Compiler error follows:


fran@atlantis:~/tmp/passing_elemental$ gfortran Use.f03 Program.f03 -o
Program.bin 
Program.f03:15:0:

   15 |   call check_array( elements%get_i() )
  | 
internal compiler error: in gfc_conv_expr_descriptor, at
fortran/trans-array.c:7348
Please submit a full bug report,
with preprocessed source if appropriate.
See  for instructions.
fran@atlantis:~/tmp/passing_elemental$

[Bug fortran/103957] ICE passing return value from elemental type bound procedure

2022-01-09 Thread ffadrique at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103957

--- Comment #1 from Fran Martinez Fadrique  ---
Created attachment 52150
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=52150&action=edit
Main program where the error appears