[Bug fortran/69636] ICE(s) on using option -fmodule-private

2023-02-09 Thread cvs-commit at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69636

--- Comment #10 from CVS Commits  ---
The master branch has been updated by Harald Anlauf :

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

commit r13-5760-ga618b45ac41cf480f54c4fa4014aed6218931290
Author: Harald Anlauf 
Date:   Thu Feb 9 21:16:14 2023 +0100

Fortran: catch invalid kind in character conversion [PR69636,PR103779]

gcc/fortran/ChangeLog:

PR fortran/69636
PR fortran/103779
* intrinsic.cc (gfc_convert_chartype): Recover on invalid character
kind in conversion instead of generating an internal error.

gcc/testsuite/ChangeLog:

PR fortran/69636
PR fortran/103779
* gfortran.dg/pr103779.f90: New test.

Co-authored-by: Steven G. Kargl 

[Bug fortran/69636] ICE(s) on using option -fmodule-private

2023-02-08 Thread anlauf at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69636

anlauf at gcc dot gnu.org changed:

   What|Removed |Added

   Keywords||accepts-invalid

--- Comment #9 from anlauf at gcc dot gnu.org ---
(In reply to anlauf from comment #8)

Commenting out this line:

>   private :: cx_plus_int! <- why does this make a difference?

and adding in the main:

  print *, cx_plus_int(a, 2)

make the code compile, while I believe it shouldn't due to the "private"
statement in m.  (This version is rejected by other compilers.)

[Bug fortran/69636] ICE(s) on using option -fmodule-private

2023-02-08 Thread anlauf at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69636

--- Comment #8 from anlauf at gcc dot gnu.org ---
A slightly reduced & rewritten variant of the code in comment#6:

module m
  implicit none
  private
  public  :: cx, operator(+)
  private :: cx_plus_int! <- why does this make a difference?
  type cx
integer :: re
  end type
  interface operator (+)
module procedure cx_plus_int
  end interface
contains
  function cx_plus_int (z, r)
  entryint_plus_cx (r, z)   ! <- why does this make a difference?
type(cx), intent(in) :: z
integer,  intent(in) :: r
type(cx) :: cx_plus_int, int_plus_cx
cx_plus_int%re = z%re + r
  end function
end module

program p
  use m
  type(cx) :: a = cx(1)
  print *, (a + 2)
end

So there are multiple issues at work:
- the explicit "private :: cx_plus_int" should not make a difference;
  I think I've seen a related PR
- adding an entry that is otherwise unused changes the module
- the modified module when read seems to obstruct finding cx_plus_int,
  although the symbols still appears to be there...

[Bug fortran/69636] ICE(s) on using option -fmodule-private

2023-02-07 Thread anlauf at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69636

anlauf at gcc dot gnu.org changed:

   What|Removed |Added

 CC||anlauf at gcc dot gnu.org

--- Comment #7 from anlauf at gcc dot gnu.org ---
The ICE for the reduced testcase in comment#2 is fixed by:

diff --git a/gcc/fortran/intrinsic.cc b/gcc/fortran/intrinsic.cc
index 68f481473b4..97ff1d640d7 100644
--- a/gcc/fortran/intrinsic.cc
+++ b/gcc/fortran/intrinsic.cc
@@ -5419,7 +5419,9 @@ gfc_convert_chartype (gfc_expr *expr, gfc_typespec *ts)
   gcc_assert (expr->ts.type == BT_CHARACTER && ts->type == BT_CHARACTER);

   sym = find_char_conv (>ts, ts);
-  gcc_assert (sym);
+  if (sym == NULL)
+return false;
+//  gcc_assert (sym);

   /* Insert a pre-resolved function call to the right function.  */
   old_where = expr->where;

[Bug fortran/69636] ICE(s) on using option -fmodule-private

2016-02-04 Thread dominiq at lps dot ens.fr
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69636

Dominique d'Humieres  changed:

   What|Removed |Added

 Status|UNCONFIRMED |NEW
   Last reconfirmed||2016-02-04
 Ever confirmed|0   |1

--- Comment #2 from Dominique d'Humieres  ---
> Placing statement "private" explicit in source, reducing a bit,
> then compiling without "-fmodule-private" :

Even simpler

character(1,char_t) function test1()
  test1 = 'A'
end function test1

function_kinds_3_red.f90:1:12:

 character(1,char_t) function test1()
1
Error: Parameter 'char_t' at (1) has not been declared or is a variable, which
does not reduce to a constant expression
f951: internal compiler error: Segmentation fault: 11

"-fmodule-private" triggers errors for used names not marked as PUBLIC, some
errors in turn may have a recovery problem, hence trigger an ICE.

[Bug fortran/69636] ICE(s) on using option -fmodule-private

2016-02-04 Thread gerhard.steinmetz.fort...@t-online.de
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69636

--- Comment #3 from Gerhard Steinmetz  
---
Thank you for commenting.

A few comments will follow with melt down (simplified) test cases. 
Hopefully, nothing gets lost.

It might have been better to post a handful of separate problem reports
instead of this lengthy one. But on the other hand, theses issues belong
together thematically. And there are several more cases/variants.

My best regards.

[Bug fortran/69636] ICE(s) on using option -fmodule-private

2016-02-04 Thread gerhard.steinmetz.fort...@t-online.de
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69636

--- Comment #4 from Gerhard Steinmetz  
---
Applying same operations as in comment 1 to derived_external_function_1.f90 :


$ cat z2.f90
module m
  private
  type t
integer g
  end type
end

type(t) function f() result(ff)
  use m
  ff%g = 42
end


$ gfortran-6 -c z2.f90
f951: internal compiler error: Segmentation fault

[Bug fortran/69636] ICE(s) on using option -fmodule-private

2016-02-04 Thread gerhard.steinmetz.fort...@t-online.de
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69636

--- Comment #6 from Gerhard Steinmetz  
---
And for visibility of functions etc., a reduced and modified entry_16.f90 :


$ cat z4.f90
module complex
  private :: cx_cadr, cx_radc
  type cx
integer :: re
integer :: im
  end type
  interface operator (+)
module procedure cx_cadr, cx_radc
  end interface
contains
  function cx_cadr(z, r)
  entry cx_radc(r, z)
type(cx), intent(in) :: z
integer, intent(in) :: r
type(cx) :: cx_cadr, cx_radc
cx_cadr%re = z%re + r
cx_cadr%im = z%im
  end function
end module

program p
  use complex
  type(cx) :: a = cx(1, 2)
  print *, (a + 2)
  print *, (2 + a)
end


$ gfortran-6 -c z4.f90
f951: internal compiler error: Unable to find symbol 'cx_cadr'

[Bug fortran/69636] ICE(s) on using option -fmodule-private

2016-02-04 Thread gerhard.steinmetz.fort...@t-online.de
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69636

--- Comment #5 from Gerhard Steinmetz  
---
The ICE with  associate_6.f03  and  -fmodule-private
depends on including "implicit none" in main program :


$ cat z3.f90
module m
  private
contains
  pure function func (n) result (f)
integer, intent(in) :: n
integer :: f(n)
f = 0.0
  end function
end module

program p
  use m
  implicit none
  associate (arr => func (4))
print *, arr(1)
  end associate
end


$ gfortran-6 -c z3.f90
z3.f90:14:20:

   associate (arr => func (4))
1
Error: Function 'func' at (1) has no IMPLICIT type
z3.f90:14:28:

   associate (arr => func (4))
1
Error: Symbol 'arr' at (1) has no IMPLICIT type
f951: internal compiler error: find_array_spec(): Missing spec

---


$ cat z3b.f90
module m
  private
contains
  pure function func (n) result (f)
integer, intent(in) :: n
integer :: f(n)
f = 0.0
  end function
end module

program p
  use m
! implicit none
  associate (arr => func (4))
print *, arr(1)
  end associate
end


$ gfortran-6 -c z3b.f90
z3b.f90:14:28:

   associate (arr => func (4))
1
Error: Associate-name 'arr' at (1) is used as array

[Bug fortran/69636] ICE(s) on using option -fmodule-private

2016-02-03 Thread gerhard.steinmetz.fort...@t-online.de
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69636

--- Comment #1 from Gerhard Steinmetz  
---
To begin with a short example, namely function_kinds_3.f90.

Placing statement "private" explicit in source, reducing a bit,
then compiling without "-fmodule-private" :


$ cat z1.f90
module m
  private
  integer, parameter :: char_t = kind('a')
end module m

character(1,char_t) function test1()
  use m
  test1 = 'A'
end function test1


$ gfortran-6 --version
GNU Fortran (SUSE Linux) 6.0.0 20160121 (experimental) [trunk revision 232670]


$ gfortran-6 -c z1.f90
z1.f90:6:12:

 character(1,char_t) function test1()
1

Error: Parameter ‘char_t’ at (1) has not been declared or is a variable, which
does not reduce to a constant expression
f951: internal compiler error: in gfc_convert_chartype, at
fortran/intrinsic.c:4812


$ gfortran-5.3.1 -c z1.f90
(null):0: confused by earlier errors, bailing out


$ gfortran-4.9.0 -c z1.f90
f951: internal compiler error: in gfc_convert_chartype, at
fortran/intrinsic.c:4623