[Bug fortran/114874] [14/15 Regression] ICE with select type, type is (character(*)), and substring

2024-05-22 Thread anlauf at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114874

anlauf at gcc dot gnu.org changed:

   What|Removed |Added

 CC||ryan.mulhall at noaa dot gov

--- Comment #12 from anlauf at gcc dot gnu.org ---
*** Bug 115193 has been marked as a duplicate of this bug. ***

[Bug fortran/114874] [14/15 Regression] ICE with select type, type is (character(*)), and substring

2024-05-17 Thread pault at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114874

Paul Thomas  changed:

   What|Removed |Added

 Resolution|--- |FIXED
 Status|NEW |RESOLVED

--- Comment #11 from Paul Thomas  ---
Hi Harald,

Your comments have been implemented and the patch committed to both affected
branches.

Thanks for the report and your help in honing up the fix.

Paul

[Bug fortran/114874] [14/15 Regression] ICE with select type, type is (character(*)), and substring

2024-05-17 Thread cvs-commit at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114874

--- Comment #10 from GCC Commits  ---
The releases/gcc-14 branch has been updated by Paul Thomas :

https://gcc.gnu.org/g:c887341432bb71cf5540d54955ad7265b0aaca77

commit r14-10216-gc887341432bb71cf5540d54955ad7265b0aaca77
Author: Paul Thomas 
Date:   Fri May 17 15:19:26 2024 +0100

Fortran: Fix select type regression due to r14-9489 [PR114874]

2024-05-17  Paul Thomas  

gcc/fortran
PR fortran/114874
* gfortran.h: Add 'assoc_name_inferred' to gfc_namespace.
* match.cc (gfc_match_select_type): Set 'assoc_name_inferred'
in select type namespace if the selector has inferred type.
* primary.cc (gfc_match_varspec): If a select type temporary
is apparently scalar and a left parenthesis has been detected,
check the current namespace has 'assoc_name_inferred' set. If
so, set inferred_type.
* resolve.cc (resolve_variable): If the namespace of a select
type temporary is marked with 'assoc_name_inferred' call
gfc_fixup_inferred_type_refs to ensure references are OK.
(gfc_fixup_inferred_type_refs): Catch invalid array refs..

gcc/testsuite/
PR fortran/114874
* gfortran.dg/pr114874_1.f90: New test for valid code.
* gfortran.dg/pr114874_2.f90: New test for invalid code.

(cherry picked from commit 5f5074fe7aaf9524defb265299a985eecba7f914)

[Bug fortran/114874] [14/15 Regression] ICE with select type, type is (character(*)), and substring

2024-05-17 Thread cvs-commit at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114874

--- Comment #9 from GCC Commits  ---
The master branch has been updated by Paul Thomas :

https://gcc.gnu.org/g:5f5074fe7aaf9524defb265299a985eecba7f914

commit r15-633-g5f5074fe7aaf9524defb265299a985eecba7f914
Author: Paul Thomas 
Date:   Fri May 17 15:19:26 2024 +0100

Fortran: Fix select type regression due to r14-9489 [PR114874]

2024-05-17  Paul Thomas  

gcc/fortran
PR fortran/114874
* gfortran.h: Add 'assoc_name_inferred' to gfc_namespace.
* match.cc (gfc_match_select_type): Set 'assoc_name_inferred'
in select type namespace if the selector has inferred type.
* primary.cc (gfc_match_varspec): If a select type temporary
is apparently scalar and a left parenthesis has been detected,
check the current namespace has 'assoc_name_inferred' set. If
so, set inferred_type.
* resolve.cc (resolve_variable): If the namespace of a select
type temporary is marked with 'assoc_name_inferred' call
gfc_fixup_inferred_type_refs to ensure references are OK.
(gfc_fixup_inferred_type_refs): Catch invalid array refs..

gcc/testsuite/
PR fortran/114874
* gfortran.dg/pr114874_1.f90: New test for valid code.
* gfortran.dg/pr114874_2.f90: New test for invalid code.

[Bug fortran/114874] [14/15 Regression] ICE with select type, type is (character(*)), and substring

2024-05-07 Thread rguenth at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114874

Richard Biener  changed:

   What|Removed |Added

   Target Milestone|14.0|14.2

--- Comment #8 from Richard Biener  ---
GCC 14.1 is being released, retargeting bugs to GCC 14.2.

[Bug fortran/114874] [14/15 Regression] ICE with select type, type is (character(*)), and substring

2024-05-04 Thread pault at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114874

Paul Thomas  changed:

   What|Removed |Added

   Assignee|unassigned at gcc dot gnu.org  |pault at gcc dot gnu.org

--- Comment #7 from Paul Thomas  ---
Created attachment 58104
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=58104=edit
Fix for this PR

This seems to be the best fix. I have tried several different approaches in the
last two days but it has been an uphill struggle against the state of the block
namespaces at this stage of the compilation.

I'll think about it for another day or so before submitting.

Cheers

Paul

[Bug fortran/114874] [14/15 Regression] ICE with select type, type is (character(*)), and substring

2024-04-30 Thread pault at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114874

--- Comment #6 from Paul Thomas  ---
(In reply to anlauf from comment #3)
> Adding Paul, hoping that he can tell what changed for SELECT TYPE recently.

Needless to say, the regression is caused by r14-9489.

I have a fix that regtests OK but causes a regression in an, as yet, untested
corner:

  subroutine foobar
type :: t
  integer :: i
end type
class(*), allocatable :: c
c = t (1)
select type (c)
  type is (t)
if (c(1)%i .ne. 1) stop 5 ! This now ICEs
end select
  end

My efforts have been interrupted by a failure of make-install, which seems to
happen every few months. I rather think that I should go back to magnetic
drives, rather than SSD.

It will now have to wait until tomorrow.

Paul

[Bug fortran/114874] [14/15 Regression] ICE with select type, type is (character(*)), and substring

2024-04-30 Thread rguenth at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114874

Richard Biener  changed:

   What|Removed |Added

   Target Milestone|--- |14.0

[Bug fortran/114874] [14/15 Regression] ICE with select type, type is (character(*)), and substring

2024-04-30 Thread pault at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114874

--- Comment #5 from Paul Thomas  ---
(In reply to Paul Thomas from comment #4)
> (In reply to anlauf from comment #3)
> > Adding Paul, hoping that he can tell what changed for SELECT TYPE recently.
> 

When c is an array, it compiles and runs fine with mainline. The parse-tree
looks sensible too, unlike the scalar version.

program p
  implicit none
  class(*), allocatable :: c(:)
  c = ['abc']
  select type (c)
  type is (character(*))
 print *, c
 print *, c(1)(2:2)  ! Doesn't ICE
  end select
end

Paul

[Bug fortran/114874] [14/15 Regression] ICE with select type, type is (character(*)), and substring

2024-04-29 Thread pault at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114874

Paul Thomas  changed:

   What|Removed |Added

 Ever confirmed|0   |1
   Last reconfirmed||2024-04-29
 Status|UNCONFIRMED |NEW

--- Comment #4 from Paul Thomas  ---
(In reply to anlauf from comment #3)
> Adding Paul, hoping that he can tell what changed for SELECT TYPE recently.

Hmmm! Nothing that I am aware of. I'll take a look tomorrow, The changes are
most strange.

Why do I get that horrible feeling?

Paul

[Bug fortran/114874] [14/15 Regression] ICE with select type, type is (character(*)), and substring

2024-04-29 Thread anlauf at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114874

anlauf at gcc dot gnu.org changed:

   What|Removed |Added

 CC||pault at gcc dot gnu.org

--- Comment #3 from anlauf at gcc dot gnu.org ---
Adding Paul, hoping that he can tell what changed for SELECT TYPE recently.

[Bug fortran/114874] [14/15 Regression] ICE with select type, type is (character(*)), and substring

2024-04-29 Thread anlauf at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114874

--- Comment #2 from anlauf at gcc dot gnu.org ---
The dump-fortran-original shows the following difference between 13 and 14:

@@ -58,7 +58,7 @@
   code:
   ASSIGN p:c 'abc'

-  BLOCK 
+  SELECT TYPE 
 symtree: '__tmp_CHARACTER_0_1'|| symbol: '__tmp_CHARACTER_0_1' 
   type spec : (CHARACTER () 1)
   attributes: (VARIABLE  SELECT-TYPE-TEMPORARY ASSOCIATE-VAR)
@@ -66,7 +66,7 @@
   type spec : (UNKNOWN 0)
   attributes: (LABEL )

-SELECT TYPE _loc[((p:c % _vptr))]
+SELECT CASE _loc[((p:c % _vptr))]
 CASE (_loc[((p:__vtab_CHARACTER_1_))] 85893463) 

 ASSOCIATE   = p:c % _data
@@ -74,11 +74,11 @@
 type spec : (UNKNOWN 0)
 attributes: (LABEL )
   WRITE UNIT=6 FMT=-1
-  TRANSFER block@1:__tmp_CHARACTER_0_1(2:2)
+  TRANSFER block@1:__tmp_CHARACTER_0_1(UNKNOWN)
   DT_END
 END ASSOCIATE 
 END SELECT
-  END BLOCK 
+  END SELECT TYPE 

 CONTAINS

[Bug fortran/114874] [14/15 Regression] ICE with select type, type is (character(*)), and substring

2024-04-27 Thread anlauf at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114874

--- Comment #1 from anlauf at gcc dot gnu.org ---
(In reply to anlauf from comment #0)
> The following code fails for me with latest 14-branch/15-release candidate:

Oops, I meant: 14-release candidate/15-mainline after branching...

[Bug fortran/114874] [14/15 Regression] ICE with select type, type is (character(*)), and substring

2024-04-27 Thread anlauf at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114874

anlauf at gcc dot gnu.org changed:

   What|Removed |Added

  Known to work||10.5.0, 11.4.1, 12.3.1,
   ||13.2.1
   Keywords||ice-on-valid-code
   Priority|P3  |P4