public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/47984] New: Pointer dummy argument mismatch not detected by Fortran compiler
@ 2011-03-04 8:31 thenlich at users dot sourceforge.net
2011-03-04 15:47 ` [Bug fortran/47984] " kargl at gcc dot gnu.org
` (5 more replies)
0 siblings, 6 replies; 7+ messages in thread
From: thenlich at users dot sourceforge.net @ 2011-03-04 8:31 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47984
Summary: Pointer dummy argument mismatch not detected by
Fortran compiler
Product: gcc
Version: 4.6.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: fortran
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: thenlich@users.sourceforge.net
Created attachment 23539
--> http://gcc.gnu.org/bugzilla/attachment.cgi?id=23539
Test case
The Fortran compiler does not detect a mismatch between an actual argument (not
a pointer) and a dummy argument in a procedure (which is a pointer, by mistake)
in this example:
program test_pointer
type :: t
integer :: i = 7
end type
type(t), target :: a
call testsub(a%i)
contains
subroutine testsub(p)
integer, pointer, intent(in) :: p
print *, p
end subroutine
end
Result: The program compiles without errors.
Expected result: The compiler should report an error like
test_pointer.f90:6.17:
call testsub(a%i)
1
Error: Actual argument for 'p' must be a pointer at (1)
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug fortran/47984] Pointer dummy argument mismatch not detected by Fortran compiler
2011-03-04 8:31 [Bug fortran/47984] New: Pointer dummy argument mismatch not detected by Fortran compiler thenlich at users dot sourceforge.net
@ 2011-03-04 15:47 ` kargl at gcc dot gnu.org
2011-03-04 17:10 ` burnus at gcc dot gnu.org
` (4 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: kargl at gcc dot gnu.org @ 2011-03-04 15:47 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47984
kargl at gcc dot gnu.org changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |kargl at gcc dot gnu.org
--- Comment #1 from kargl at gcc dot gnu.org 2011-03-04 15:46:46 UTC ---
troutmask:sgk[205] gfc4x -o z -std=f2003 a.f90
a.f90:6.17:
call testsub(a%i)
1
Error: Fortran 2008: Non-pointer actual argument at (1) to pointer dummy 'p'
troutmask:sgk[212] svn blame interface.c | more
163262 burnus if (a->expr->expr_type != EXPR_NULL
163262 burnus && (gfc_option.allow_std & GFC_STD_F2008) == 0
163262 burnus && compare_pointer (f->sym, a->expr) == 2)
163262 burnus {
163262 burnus if (where)
163262 burnus gfc_error ("Fortran 2008: Non-pointer actual
argument at %L to "
163262 burnus "pointer dummy '%s'",
&a->expr->where,f->sym->name);
163262 burnus return 0;
163262 burnus }
troutmask:sgk[213] svn log -r 163262 |more
------------------------------------------------------------------------
r163262 | burnus | 2010-08-15 08:47:11 -0700 (Sun, 15 Aug 2010) | 12 lines
2010-08-15 Tobias Burnus <burnus@net-b.de>
* interface.c (compare_pointer, ): Allow passing TARGETs to
pointers dummies with intent(in).
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug fortran/47984] Pointer dummy argument mismatch not detected by Fortran compiler
2011-03-04 8:31 [Bug fortran/47984] New: Pointer dummy argument mismatch not detected by Fortran compiler thenlich at users dot sourceforge.net
2011-03-04 15:47 ` [Bug fortran/47984] " kargl at gcc dot gnu.org
@ 2011-03-04 17:10 ` burnus at gcc dot gnu.org
2011-03-04 18:58 ` thenlich at users dot sourceforge.net
` (3 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: burnus at gcc dot gnu.org @ 2011-03-04 17:10 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47984
Tobias Burnus <burnus at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
CC| |burnus at gcc dot gnu.org
Resolution| |INVALID
--- Comment #2 from Tobias Burnus <burnus at gcc dot gnu.org> 2011-03-04 17:09:50 UTC ---
And without INTENT(IN):
call testsub(a%i)
1
Error: Actual argument for 'p' must be a pointer at (1)
Close as INVALID. If you think that's an error, feel free to reopen.
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug fortran/47984] Pointer dummy argument mismatch not detected by Fortran compiler
2011-03-04 8:31 [Bug fortran/47984] New: Pointer dummy argument mismatch not detected by Fortran compiler thenlich at users dot sourceforge.net
2011-03-04 15:47 ` [Bug fortran/47984] " kargl at gcc dot gnu.org
2011-03-04 17:10 ` burnus at gcc dot gnu.org
@ 2011-03-04 18:58 ` thenlich at users dot sourceforge.net
2011-03-04 19:16 ` sgk at troutmask dot apl.washington.edu
` (2 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: thenlich at users dot sourceforge.net @ 2011-03-04 18:58 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47984
--- Comment #3 from Thomas Henlich <thenlich at users dot sourceforge.net> 2011-03-04 18:58:06 UTC ---
Sorry, I don't understand why you consider the bug report invalid. You may very
well be correct, but please explain. I am not such a Fortran expert, so I may
have missed something here.
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug fortran/47984] Pointer dummy argument mismatch not detected by Fortran compiler
2011-03-04 8:31 [Bug fortran/47984] New: Pointer dummy argument mismatch not detected by Fortran compiler thenlich at users dot sourceforge.net
` (2 preceding siblings ...)
2011-03-04 18:58 ` thenlich at users dot sourceforge.net
@ 2011-03-04 19:16 ` sgk at troutmask dot apl.washington.edu
2011-03-04 19:40 ` burnus at gcc dot gnu.org
2011-03-07 6:26 ` thenlich at users dot sourceforge.net
5 siblings, 0 replies; 7+ messages in thread
From: sgk at troutmask dot apl.washington.edu @ 2011-03-04 19:16 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47984
--- Comment #4 from Steve Kargl <sgk at troutmask dot apl.washington.edu> 2011-03-04 19:16:27 UTC ---
On Fri, Mar 04, 2011 at 06:58:19PM +0000, thenlich at users dot sourceforge.net
wrote:
> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47984
>
> --- Comment #3 from Thomas Henlich <thenlich at users dot sourceforge.net> 2011-03-04 18:58:06 UTC ---
> Sorry, I don't understand why you consider the bug report invalid. You may very
> well be correct, but please explain. I am not such a Fortran expert, so I may
> have missed something here.
>
gfortran has some support for Fortran 2003 and Fortran 2008
features. Under Fortran 2008, your program is a valid program.
Under Fortran 2003 (and earlier), your program is invalid.
By default gfortran accepts everything including vendor
extensions. If you want to restrict gfortran to a particular
standard, then you need to use the -std option.
-std=gnu Default behavior. Accept a whole lotta garbage.
-std=f95 Restricted to Fortran 95 standard.
-std=f2003 Restricted to Fortran 2003 standard.
-std=f2008 Restricted to Fortran 2008 standard.
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug fortran/47984] Pointer dummy argument mismatch not detected by Fortran compiler
2011-03-04 8:31 [Bug fortran/47984] New: Pointer dummy argument mismatch not detected by Fortran compiler thenlich at users dot sourceforge.net
` (3 preceding siblings ...)
2011-03-04 19:16 ` sgk at troutmask dot apl.washington.edu
@ 2011-03-04 19:40 ` burnus at gcc dot gnu.org
2011-03-07 6:26 ` thenlich at users dot sourceforge.net
5 siblings, 0 replies; 7+ messages in thread
From: burnus at gcc dot gnu.org @ 2011-03-04 19:40 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47984
--- Comment #5 from Tobias Burnus <burnus at gcc dot gnu.org> 2011-03-04 19:39:32 UTC ---
(In reply to comment #3)
> Sorry, I don't understand why you consider the bug report invalid.
> You may very well be correct, but please explain. I am not such a
> Fortran expert, so I may have missed something here.
I thought the error message (with -std=f2003) in comment 1 was rather clear,
seemingly that's not the case:
call testsub(a%i)
1
Error: Fortran 2008: Non-pointer actual argument at (1) to pointer dummy 'p'
That means: It is allowed in Fortran 2008, but not before. (See below for the
details.)
* * *
If one looks into the Fortran 2008 standard
(http://gcc.gnu.org/wiki/GFortranStandards), one finds the following:
"12.5.2.7 Pointer dummy variables"
"If the dummy argument does not have the INTENT (IN), the actual argument shall
be a pointer. Otherwise, the actual argument shall be a pointer or a valid
target for the dummy pointer in a pointer assignment statement. If the actual
argument is not a pointer, the dummy pointer becomes pointer associated with
the actual argument."
Thus, the crucial points are:
(a) the dummy argument has INTENT(IN) - which "p" has
(b) the actual argument has the TARGET attribute which "a" and thus "a%i" has
The INTENT(IN) for the pointer ensures that the pointer association is not
modified -- and TARGET avoids alias issues. Thus, there is no technical reason
for not allowing it -- which the standardization committee seemingly also
realized. Thus, it is now allowed in Fortran 2008.
* * *
For an overview about the new Fortran 2008 features, see also
ftp://ftp.nag.co.uk/sc22wg5/N1801-N1850/N1828.pdf
For the already implemented F2008 features, see
http://gcc.gnu.org/wiki/Fortran2008Status
or in the release notes:
http://gcc.gnu.org/wiki/GFortran#news
http://gcc.gnu.org/gcc-4.6/changes.html
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug fortran/47984] Pointer dummy argument mismatch not detected by Fortran compiler
2011-03-04 8:31 [Bug fortran/47984] New: Pointer dummy argument mismatch not detected by Fortran compiler thenlich at users dot sourceforge.net
` (4 preceding siblings ...)
2011-03-04 19:40 ` burnus at gcc dot gnu.org
@ 2011-03-07 6:26 ` thenlich at users dot sourceforge.net
5 siblings, 0 replies; 7+ messages in thread
From: thenlich at users dot sourceforge.net @ 2011-03-07 6:26 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47984
--- Comment #6 from Thomas Henlich <thenlich at users dot sourceforge.net> 2011-03-07 06:26:24 UTC ---
RTFM, I should have.
Thank you for your help.
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2011-03-07 6:26 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-03-04 8:31 [Bug fortran/47984] New: Pointer dummy argument mismatch not detected by Fortran compiler thenlich at users dot sourceforge.net
2011-03-04 15:47 ` [Bug fortran/47984] " kargl at gcc dot gnu.org
2011-03-04 17:10 ` burnus at gcc dot gnu.org
2011-03-04 18:58 ` thenlich at users dot sourceforge.net
2011-03-04 19:16 ` sgk at troutmask dot apl.washington.edu
2011-03-04 19:40 ` burnus at gcc dot gnu.org
2011-03-07 6:26 ` thenlich at users dot sourceforge.net
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).