[Bug fortran/122290] PDT - gfortan rejects real intrinsic in default initialization & generic binding
pault at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Tue Oct 21 22:11:07 GMT 2025
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=122290
--- Comment #8 from Paul Thomas <pault at gcc dot gnu.org> ---
Created attachment 62603
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=62603&action=edit
Fix for this PR
The attached patch regtests OK. Some tweaking/checking is still need but this
now runs as expected:
module hyperparameters_m
implicit none
type hyperparameters_t(k)
integer, kind :: k = kind(1.)
real(k) :: learning_rate_ = real(1.5,k)
contains
generic :: operator(==) => default_real_equals
procedure default_real_equals
end type
interface
logical module function default_real_equals(lhs, rhs)
implicit none
class(hyperparameters_t), intent(in) :: lhs, rhs
end function
end interface
end module
submodule(hyperparameters_m) hyperparameters_s
contains
logical module function default_real_equals(lhs, rhs)
implicit none
class(hyperparameters_t), intent(in) :: lhs, rhs
default_real_equals = (lhs%learning_rate_ == rhs%learning_rate_)
end function
end submodule
use hyperparameters_m
type (hyperparameters_t) :: a, b
print *, a%learning_rate_, default_real_equals(a, b)
a%learning_rate_ = real(2.5,a%k)
print *, a%learning_rate_, default_real_equals(a, b)
end
More information about the Gcc-bugs
mailing list