- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi.
The following code
module mod1
implicit none
private
save
generic, public :: x => x1
contains
subroutine x1()
end subroutine
end module
module mod2
use mod1
implicit none
private
save
generic, public :: x => x2
contains
subroutine x2(v)
integer, intent(in) :: v
end subroutine
end module
fails to compile with
generic.f90(22): error #6270: This generic entity has already been assigned the PRIVATE attribute. [X]
generic, public :: x => x2
-----------------------^
compilation aborted for generic.f90 (code 1)
But this code compiles without issues
module mod1
implicit none
private
save
interface x
module procedure x1
end interface
public x
contains
subroutine x1()
end subroutine
end module
module mod2
use mod1
implicit none
private
save
interface x
module procedure x2
end interface
public x
contains
subroutine x2(v)
integer, intent(in) :: v
end subroutine
end module
So, is it a bug or is the compiler right at complaining?
Compiled with the following versions, with same results:
ifx version 2023.1.0
ifort version 2021.9.0
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
This is interesting. I'll note that the GENERIC statement outside of a type declaration is a F2018 feature, which is why. when I tried it with the NAG compiler, it complained about the syntax.
I'd say that this is a compiler bug, as if you do this instead:
generic :: x => x2
public :: x
the compiler is happy.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks for the reply @Steve_Lionel .
It's good to see that, even though you retired, you're also still around.
And back on the topic: there's also the minor issue of always requiring "::", even without the access-spec.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
@jwmwalrus wrote:
And back on the topic: there's also the minor issue of always requiring "::", even without the access-spec.
That's required by the standard:
R1510 generic-stmt is GENERIC [ , access-spec ] :: generic-spec => specific-procedure-list
Note that the :: is not denoted as optional.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hmm... I was using this document as a guide for what's new in f2018:
http://armnlib.uqam.ca/PDF/The_New_Features_of_Fortran_2018.pdf
At section 5.23 the GENERIC is mentioned. So it seems the syntax there is wrong.
Thanks.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Indeed, that is an error in the document. It's a shame none of us caught it in review.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
bug ID is CMPLRLLVM-48226

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page