[Bug fortran/85877] [8/9/10/11 Regression] ICE in fold_convert_loc, at fold-const.c:2449

2020-12-27 Thread anlauf at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85877

--- Comment #6 from anlauf at gcc dot gnu.org ---
Digging some more, it appears that the logic in resolve.c is incomplete.
There is some inconsistency between what is dealt with in resolve_symbol
and in resolve_fl_procedure.

resolve_symbol:

15637 if (sym->attr.is_bind_c && sym->attr.use_assoc == 0
15638 && sym->attr.dummy == 0 && sym->attr.flavor != FL_PROCEDURE
15639 && sym->attr.flavor != FL_DERIVED)

Commenting out the second half of line 15638 (sym->attr.flavor != FL_PROCEDURE)
fixed the issue, but hell breaks loose in regtesting...

[Bug fortran/85877] [8/9/10/11 Regression] ICE in fold_convert_loc, at fold-const.c:2449

2020-12-22 Thread anlauf at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85877

anlauf at gcc dot gnu.org changed:

   What|Removed |Added

 CC||anlauf at gcc dot gnu.org
   Keywords|ice-on-valid-code   |ice-on-invalid-code

--- Comment #5 from anlauf at gcc dot gnu.org ---
I doubt that the testcase in comment#0 is actually valid.

In fact, it is empirically rejected by most compilers.  E.g. Intel v21:

pr85877.f90(2): error #8067: If any bind-entity in a bind-stmt is an
entity-name, the bind-stmt shall appear in the specification part of a module. 
 [F]
  bind(c) f
--^
pr85877.f90(3): error #6410: This name has not been declared as an array or a
function.   [F]
  x = f()
--^


The F2018 standard has a few things here, e.g. on the BIND statement

! 8.6.4 BIND statement
! ...
! The BIND statement specifies the BIND attribute for a list of variables
! and common blocks.

! 18.3.6 Interoperability of procedures and procedure interfaces

! A Fortran procedure is interoperable if and only if it has the BIND
! attribute, that is, if its interface is specified with a
! proc-language-binding-spec.

Since there is no explicit interface, c.f.

! 15.4.2.2 Explicit interface

! Within the scope of a procedure identifier, the procedure shall have an
! explicit interface if it is not a statement function and
! ...
! (6) the procedure has the BIND attribute.


While I'm not sure that Intel has all the wording right, the reason is
almost right. ;-)  Thus changing to ice-on-invalid.