* [Bug fortran/63797] Bogus ambiguous reference to 'sqrt'
2014-11-09 17:13 [Bug fortran/63797] New: Bogus ambiguous reference to 'sqrt' burnus at gcc dot gnu.org
@ 2014-11-09 17:15 ` burnus at gcc dot gnu.org
2021-04-10 0:29 ` chrisonian at gmail dot com
` (11 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: burnus at gcc dot gnu.org @ 2014-11-09 17:15 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63797
Tobias Burnus <burnus at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Last reconfirmed| |2014-11-09
CC| |pault at gcc dot gnu.org
Ever confirmed|0 |1
Known to fail| |4.4.5, 4.8.3, 5.0
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug fortran/63797] Bogus ambiguous reference to 'sqrt'
2014-11-09 17:13 [Bug fortran/63797] New: Bogus ambiguous reference to 'sqrt' burnus at gcc dot gnu.org
2014-11-09 17:15 ` [Bug fortran/63797] " burnus at gcc dot gnu.org
@ 2021-04-10 0:29 ` chrisonian at gmail dot com
2021-04-12 21:48 ` kargl at gcc dot gnu.org
` (10 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: chrisonian at gmail dot com @ 2021-04-10 0:29 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63797
chrisonian at gmail dot com changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |chrisonian at gmail dot com
--- Comment #1 from chrisonian at gmail dot com ---
This bug is still present in versions 8.3.0, 9.3.0, 10.1.0
Testing on Cori (NERSC):
module load gcc/8.3.0
or
module load gcc/9.3.0
or
module load gcc/10.1.0
The result is the same:
gfortran test.f90
test.f90:30:8:
y = sqrt(x)
1
Error: Name 'sqrt' at (1) is an ambiguous reference to 'sqrt' from module
'(intrinsic)'
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug fortran/63797] Bogus ambiguous reference to 'sqrt'
2014-11-09 17:13 [Bug fortran/63797] New: Bogus ambiguous reference to 'sqrt' burnus at gcc dot gnu.org
2014-11-09 17:15 ` [Bug fortran/63797] " burnus at gcc dot gnu.org
2021-04-10 0:29 ` chrisonian at gmail dot com
@ 2021-04-12 21:48 ` kargl at gcc dot gnu.org
2021-04-13 20:06 ` anlauf at gcc dot gnu.org
` (9 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: kargl at gcc dot gnu.org @ 2021-04-12 21:48 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63797
kargl at gcc dot gnu.org changed:
What |Removed |Added
----------------------------------------------------------------------------
Priority|P3 |P4
CC| |kargl at gcc dot gnu.org
--- Comment #2 from kargl at gcc dot gnu.org ---
(In reply to chrisonian from comment #1)
> This bug is still present in versions 8.3.0, 9.3.0, 10.1.0
>
>
The bug likely does not effect anyone that contributes code
to GCC. Someday someone might look at this bug. Fortunately,
there is a trivial work around, e.g., change the generic-name
from 'sqrt' to 'root'. If one does this and then looks at the
contents of mod2.mod, one see the only difference shown here.
Perhaps, module.c needs to be fixed to record the generic
interface.
diff -u zxc1 zxc2
--- zxc1 2021-04-12 14:29:48.345332000 -0700
+++ zxc2 2021-04-12 14:30:04.774051000 -0700
@@ -4,7 +4,7 @@
()
-(('pair' 'mod2' 2) ('root' 'mod2' 3 4))
+(('pair' 'mod2' 2) ('sqrt' '(intrinsic)' 3 4))
()
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug fortran/63797] Bogus ambiguous reference to 'sqrt'
2014-11-09 17:13 [Bug fortran/63797] New: Bogus ambiguous reference to 'sqrt' burnus at gcc dot gnu.org
` (2 preceding siblings ...)
2021-04-12 21:48 ` kargl at gcc dot gnu.org
@ 2021-04-13 20:06 ` anlauf at gcc dot gnu.org
2021-04-13 20:49 ` anlauf at gcc dot gnu.org
` (8 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: anlauf at gcc dot gnu.org @ 2021-04-13 20:06 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63797
anlauf at gcc dot gnu.org changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |anlauf at gcc dot gnu.org
--- Comment #3 from anlauf at gcc dot gnu.org ---
(In reply to kargl from comment #2)
> The bug likely does not effect anyone that contributes code
> to GCC.
It does not affect me, but that is due my coding style (using public/private).
> Fortunately,
> there is a trivial work around, e.g., change the generic-name
> from 'sqrt' to 'root'.
Please don't do that. I already have my own generic root()...
However, why in the world does an intrinsic need to show up in the module
file in the first place? Consider:
module mod1
implicit none
real, parameter :: z = sqrt (0.0)
end module mod1
Is there a reason why the intrinsic should not be prevented from occurring
in the module file?
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug fortran/63797] Bogus ambiguous reference to 'sqrt'
2014-11-09 17:13 [Bug fortran/63797] New: Bogus ambiguous reference to 'sqrt' burnus at gcc dot gnu.org
` (3 preceding siblings ...)
2021-04-13 20:06 ` anlauf at gcc dot gnu.org
@ 2021-04-13 20:49 ` anlauf at gcc dot gnu.org
2021-04-14 1:25 ` sgk at troutmask dot apl.washington.edu
` (7 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: anlauf at gcc dot gnu.org @ 2021-04-13 20:49 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63797
--- Comment #4 from anlauf at gcc dot gnu.org ---
The following patch regtests ok and fixes the testcase:
diff --git a/gcc/fortran/module.c b/gcc/fortran/module.c
index 4db0a3ac76d..b4b7b437f86 100644
--- a/gcc/fortran/module.c
+++ b/gcc/fortran/module.c
@@ -6218,6 +6218,9 @@ write_symtree (gfc_symtree *st)
if (check_unique_name (st->name))
return;
+ if (strcmp (sym->module, "(intrinsic)") == 0)
+ return;
+
p = find_pointer (sym);
if (p == NULL)
gfc_internal_error ("write_symtree(): Symbol not written");
It even fixes the slightly reduced & refined testcase:
module mod1
implicit none
real, parameter :: z = sqrt (0.0)
end module mod1
module mod2
implicit none
type t
real :: a = 0.
end type
interface sqrt
module procedure sqrt
end interface
contains
function sqrt (a)
type(t), intent(in) :: a
type(t) :: sqrt
sqrt% a = a% a
end function sqrt
end module mod2
program test
use mod1
use mod2
implicit none
type(t) :: x, y
y = sqrt (x)
end program test
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug fortran/63797] Bogus ambiguous reference to 'sqrt'
2014-11-09 17:13 [Bug fortran/63797] New: Bogus ambiguous reference to 'sqrt' burnus at gcc dot gnu.org
` (4 preceding siblings ...)
2021-04-13 20:49 ` anlauf at gcc dot gnu.org
@ 2021-04-14 1:25 ` sgk at troutmask dot apl.washington.edu
2021-04-14 20:43 ` anlauf at gcc dot gnu.org
` (6 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: sgk at troutmask dot apl.washington.edu @ 2021-04-14 1:25 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63797
--- Comment #5 from Steve Kargl <sgk at troutmask dot apl.washington.edu> ---
On Tue, Apr 13, 2021 at 08:49:35PM +0000, anlauf at gcc dot gnu.org wrote:
> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63797
>
> --- Comment #4 from anlauf at gcc dot gnu.org ---
> The following patch regtests ok and fixes the testcase:
>
> diff --git a/gcc/fortran/module.c b/gcc/fortran/module.c
> index 4db0a3ac76d..b4b7b437f86 100644
> --- a/gcc/fortran/module.c
> +++ b/gcc/fortran/module.c
> @@ -6218,6 +6218,9 @@ write_symtree (gfc_symtree *st)
> if (check_unique_name (st->name))
> return;
>
> + if (strcmp (sym->module, "(intrinsic)") == 0)
> + return;
> +
> p = find_pointer (sym);
> if (p == NULL)
> gfc_internal_error ("write_symtree(): Symbol not written");
>
>
> It even fixes the slightly reduced & refined testcase:
>
Harald, if this survives regression testing, it might be
appropriate to commit. The only issue I can think of
is procedure pointers. I don't use them, but if one can
point at sqrt (or dsqrt, i.e., with specific vs generic
name), then is [d]sqrt needed to be written into the module?
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug fortran/63797] Bogus ambiguous reference to 'sqrt'
2014-11-09 17:13 [Bug fortran/63797] New: Bogus ambiguous reference to 'sqrt' burnus at gcc dot gnu.org
` (5 preceding siblings ...)
2021-04-14 1:25 ` sgk at troutmask dot apl.washington.edu
@ 2021-04-14 20:43 ` anlauf at gcc dot gnu.org
2021-04-14 21:37 ` sgk at troutmask dot apl.washington.edu
` (5 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: anlauf at gcc dot gnu.org @ 2021-04-14 20:43 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63797
--- Comment #6 from anlauf at gcc dot gnu.org ---
Steve, can you give an example for the procedure pointer case you mentioned?
I played a bit, but the only valid code that I can think of did not produce
a reference to sqrt in such a way that it needs to show up in the mod.
Extended testcase that compiles and also uses a procedure pointer to sqrt():
! { dg-do compile }
! PR63797 - Bogus ambiguous reference to 'sqrt'
module mod1
implicit none
real, parameter :: z = sqrt (0.0)
real :: w = sqrt (1.0)
interface
pure real function sqrt_ifc (x)
real, intent(in) :: x
end function sqrt_ifc
end interface
contains
pure function myroot () result (f)
procedure(sqrt_ifc), pointer :: f
intrinsic :: sqrt
f => sqrt
end function myroot
end module mod1
module mod2
implicit none
type t
real :: a = 0.
end type
interface sqrt
module procedure sqrt
end interface
contains
function sqrt (a)
type(t), intent(in) :: a
type(t) :: sqrt
sqrt% a = a% a
end function sqrt
end module mod2
program test
use mod1
use mod2
implicit none
type(t) :: x, y
procedure(sqrt_ifc), pointer :: root
root => myroot ()
y = sqrt (x)
y% a = sqrt (x% a) + z - w + root (x% a)
end program test
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug fortran/63797] Bogus ambiguous reference to 'sqrt'
2014-11-09 17:13 [Bug fortran/63797] New: Bogus ambiguous reference to 'sqrt' burnus at gcc dot gnu.org
` (6 preceding siblings ...)
2021-04-14 20:43 ` anlauf at gcc dot gnu.org
@ 2021-04-14 21:37 ` sgk at troutmask dot apl.washington.edu
2021-04-15 20:40 ` anlauf at gcc dot gnu.org
` (4 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: sgk at troutmask dot apl.washington.edu @ 2021-04-14 21:37 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63797
--- Comment #7 from Steve Kargl <sgk at troutmask dot apl.washington.edu> ---
On Wed, Apr 14, 2021 at 08:43:50PM +0000, anlauf at gcc dot gnu.org wrote:
> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63797
>
> --- Comment #6 from anlauf at gcc dot gnu.org ---
> Steve, can you give an example for the procedure pointer case you mentioned?
> I played a bit, but the only valid code that I can think of did not produce
> a reference to sqrt in such a way that it needs to show up in the mod.
>
> Extended testcase that compiles and also uses a procedure pointer to sqrt():
>
Your testcase is what I first thought about, but didn't try to
write. The only other instance that I might be concerned about
is
module aaa
abstract interface
function real_func (x)
real :: real_func
real, intent (in) :: x
end function real_func
end interface
procedure(real_func), pointer :: bah => sqrt
end module aaa
which looks like a default initialization. Does sqrt need to be
recorded into the module? If not, then your patch is probably ok.
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug fortran/63797] Bogus ambiguous reference to 'sqrt'
2014-11-09 17:13 [Bug fortran/63797] New: Bogus ambiguous reference to 'sqrt' burnus at gcc dot gnu.org
` (7 preceding siblings ...)
2021-04-14 21:37 ` sgk at troutmask dot apl.washington.edu
@ 2021-04-15 20:40 ` anlauf at gcc dot gnu.org
2021-04-15 20:52 ` anlauf at gcc dot gnu.org
` (3 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: anlauf at gcc dot gnu.org @ 2021-04-15 20:40 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63797
--- Comment #8 from anlauf at gcc dot gnu.org ---
(In reply to Steve Kargl from comment #7)
> which looks like a default initialization. Does sqrt need to be
> recorded into the module? If not, then your patch is probably ok.
My patch actually does not have any affect on the module file generated
for your testcase. I'll add it to my testcase and submit.
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug fortran/63797] Bogus ambiguous reference to 'sqrt'
2014-11-09 17:13 [Bug fortran/63797] New: Bogus ambiguous reference to 'sqrt' burnus at gcc dot gnu.org
` (8 preceding siblings ...)
2021-04-15 20:40 ` anlauf at gcc dot gnu.org
@ 2021-04-15 20:52 ` anlauf at gcc dot gnu.org
2021-04-16 14:24 ` cvs-commit at gcc dot gnu.org
` (2 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: anlauf at gcc dot gnu.org @ 2021-04-15 20:52 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63797
--- Comment #9 from anlauf at gcc dot gnu.org ---
Patch: https://gcc.gnu.org/pipermail/fortran/2021-April/055935.html
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug fortran/63797] Bogus ambiguous reference to 'sqrt'
2014-11-09 17:13 [Bug fortran/63797] New: Bogus ambiguous reference to 'sqrt' burnus at gcc dot gnu.org
` (9 preceding siblings ...)
2021-04-15 20:52 ` anlauf at gcc dot gnu.org
@ 2021-04-16 14:24 ` cvs-commit at gcc dot gnu.org
2021-04-18 19:48 ` cvs-commit at gcc dot gnu.org
2021-04-18 19:50 ` anlauf at gcc dot gnu.org
12 siblings, 0 replies; 14+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-04-16 14:24 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63797
--- Comment #10 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Harald Anlauf <anlauf@gcc.gnu.org>:
https://gcc.gnu.org/g:d264194c1069fbcd129222f86455137f29a5c6fd
commit r11-8218-gd264194c1069fbcd129222f86455137f29a5c6fd
Author: Harald Anlauf <anlauf@gmx.de>
Date: Fri Apr 16 16:24:31 2021 +0200
PR fortran/63797 - Bogus ambiguous reference to 'sqrt'
The interface of an intrinsic procedure is automatically explicit.
Do not write it to the module file to prevent wrong ambiguities on USE.
gcc/fortran/ChangeLog:
PR fortran/63797
* module.c (write_symtree): Do not write interface of intrinsic
procedure to module file for F2003 and newer.
gcc/testsuite/ChangeLog:
PR fortran/63797
* gfortran.dg/pr63797.f90: New test.
Co-authored-by: Paul Thomas <pault@gcc.gnu.org>
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug fortran/63797] Bogus ambiguous reference to 'sqrt'
2014-11-09 17:13 [Bug fortran/63797] New: Bogus ambiguous reference to 'sqrt' burnus at gcc dot gnu.org
` (10 preceding siblings ...)
2021-04-16 14:24 ` cvs-commit at gcc dot gnu.org
@ 2021-04-18 19:48 ` cvs-commit at gcc dot gnu.org
2021-04-18 19:50 ` anlauf at gcc dot gnu.org
12 siblings, 0 replies; 14+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-04-18 19:48 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63797
--- Comment #11 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-10 branch has been updated by Harald Anlauf
<anlauf@gcc.gnu.org>:
https://gcc.gnu.org/g:aff57bcebe534b1d92f78bdfb89a4001a6d12af2
commit r10-9712-gaff57bcebe534b1d92f78bdfb89a4001a6d12af2
Author: Harald Anlauf <anlauf@gmx.de>
Date: Fri Apr 16 16:24:31 2021 +0200
PR fortran/63797 - Bogus ambiguous reference to 'sqrt'
The interface of an intrinsic procedure is automatically explicit.
Do not write it to the module file to prevent wrong ambiguities on USE.
gcc/fortran/ChangeLog:
PR fortran/63797
* module.c (write_symtree): Do not write interface of intrinsic
procedure to module file for F2003 and newer.
gcc/testsuite/ChangeLog:
PR fortran/63797
* gfortran.dg/pr63797.f90: New test.
Co-authored-by: Paul Thomas <pault@gcc.gnu.org>
(cherry picked from commit d264194c1069fbcd129222f86455137f29a5c6fd)
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug fortran/63797] Bogus ambiguous reference to 'sqrt'
2014-11-09 17:13 [Bug fortran/63797] New: Bogus ambiguous reference to 'sqrt' burnus at gcc dot gnu.org
` (11 preceding siblings ...)
2021-04-18 19:48 ` cvs-commit at gcc dot gnu.org
@ 2021-04-18 19:50 ` anlauf at gcc dot gnu.org
12 siblings, 0 replies; 14+ messages in thread
From: anlauf at gcc dot gnu.org @ 2021-04-18 19:50 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63797
anlauf at gcc dot gnu.org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Resolution|--- |FIXED
--- Comment #12 from anlauf at gcc dot gnu.org ---
Fixed on mainline for gcc-11, and backported to 10-branch as suggested by Paul.
Closing.
Thanks for the report!
^ permalink raw reply [flat|nested] 14+ messages in thread