public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/49076] New: ASSOCIATE: Array descriptor passed to explicit-shaped dummy
@ 2011-05-20 8:01 burnus at gcc dot gnu.org
2011-05-20 22:15 ` [Bug fortran/49076] " burnus at gcc dot gnu.org
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: burnus at gcc dot gnu.org @ 2011-05-20 8:01 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49076
Summary: ASSOCIATE: Array descriptor passed to explicit-shaped
dummy
Product: gcc
Version: 4.7.0
Status: UNCONFIRMED
Keywords: wrong-code
Severity: normal
Priority: P3
Component: fortran
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: burnus@gcc.gnu.org
CC: domob@gcc.gnu.org
Reported by Andrew Baldwin at
http://groups.google.com/group/comp.lang.fortran/browse_thread/thread/b1ff1e3da48e6b27
The following program prints with gfortran:
3 4
3 4
33275912 0
With ifort 12 - and reportedly with NAG 5.2, it prints:
3 4
3 4
3 4
If one looks at the dump, one sees that in associated the function is called
as:
print_int (&bar);
That's both the case for the explicit-shape "i(2)" and for an assumed-shape
"i(:)". As "&bar" is the address of the descriptor, it works with assumed-shape
arrays - and fails with assumed-size/explicit-size arrays.
subroutine print_int (i)
integer, intent (in) :: i(2)
print *, i
end subroutine print_int
program main
interface
subroutine print_int (i)
integer, intent (in) :: i(2)
end subroutine print_int
end interface
integer, allocatable :: foo(:,:)
allocate (foo(2,2))
foo(:,1) = [1, 2]
foo(:,2) = [3, 4]
call print_int (foo(:,2))
associate (bar => foo(:,2))
print *, bar
call print_int (bar)
end associate
end program
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug fortran/49076] ASSOCIATE: Array descriptor passed to explicit-shaped dummy
2011-05-20 8:01 [Bug fortran/49076] New: ASSOCIATE: Array descriptor passed to explicit-shaped dummy burnus at gcc dot gnu.org
@ 2011-05-20 22:15 ` burnus at gcc dot gnu.org
2011-05-21 4:17 ` andrew.t.baldwin at me dot com
2013-08-27 11:13 ` [Bug fortran/49076] [F03] " mikael at gcc dot gnu.org
2 siblings, 0 replies; 4+ messages in thread
From: burnus at gcc dot gnu.org @ 2011-05-20 22:15 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49076
--- Comment #1 from Tobias Burnus <burnus at gcc dot gnu.org> 2011-05-20 21:50:25 UTC ---
If one places a break point in gfc_conv_array_parameter - which is called
during gfc_conv_procedure_call, one finds that "foo" is of type "AS_DEFERRED"
and not "AS_ASSUMED_SHAPE"; at the same time, it is not attr.allocatable, thus,
it is mishandled as one then enters:
/* Passing address of the array if it is not pointer or assumed-shape. */
if (full_array_var && g77 && !this_array_result)
[...]
if (!sym->attr.pointer
&& sym->as
&& sym->as->type != AS_ASSUMED_SHAPE
&& !sym->attr.allocatable)
{
[...]
else
se->expr = gfc_build_addr_expr (NULL_TREE, tmp);
I think one could simply mark it as AS_ASSUMED_SHAPE to get it properly
handled, even though usually only dummies are assumed-shape. Thus, one might
need to be a bit careful.
Alternatively, one could change the expr->ref from AR_FULL to AR_SECTION, but
that might be also tricky to get right.
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug fortran/49076] ASSOCIATE: Array descriptor passed to explicit-shaped dummy
2011-05-20 8:01 [Bug fortran/49076] New: ASSOCIATE: Array descriptor passed to explicit-shaped dummy burnus at gcc dot gnu.org
2011-05-20 22:15 ` [Bug fortran/49076] " burnus at gcc dot gnu.org
@ 2011-05-21 4:17 ` andrew.t.baldwin at me dot com
2013-08-27 11:13 ` [Bug fortran/49076] [F03] " mikael at gcc dot gnu.org
2 siblings, 0 replies; 4+ messages in thread
From: andrew.t.baldwin at me dot com @ 2011-05-21 4:17 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49076
--- Comment #2 from Andrew Baldwin <andrew.t.baldwin at me dot com> 2011-05-21 03:16:20 UTC ---
I'm not sure if this is directly related or not, but the following program
produces the same output as the original (with the same problem):
subroutine print_int (i)
integer, intent (in) :: i(2)
print *, i
end subroutine print_int
program main
interface
subroutine print_int (i)
integer, intent (in) :: i(2)
end subroutine print_int
end interface
type foobar
integer :: i(2)
end type foobar
type (foobar) :: foo
foo%i = [3, 4]
print *, foo%i
associate (bar => foo%i)
print *, bar
call print_int (bar)
end associate
end program
Thank you for looking into this!
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug fortran/49076] [F03] ASSOCIATE: Array descriptor passed to explicit-shaped dummy
2011-05-20 8:01 [Bug fortran/49076] New: ASSOCIATE: Array descriptor passed to explicit-shaped dummy burnus at gcc dot gnu.org
2011-05-20 22:15 ` [Bug fortran/49076] " burnus at gcc dot gnu.org
2011-05-21 4:17 ` andrew.t.baldwin at me dot com
@ 2013-08-27 11:13 ` mikael at gcc dot gnu.org
2 siblings, 0 replies; 4+ messages in thread
From: mikael at gcc dot gnu.org @ 2013-08-27 11:13 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49076
Mikael Morin <mikael at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
CC| |mikael at gcc dot gnu.org
Resolution|--- |FIXED
--- Comment #3 from Mikael Morin <mikael at gcc dot gnu.org> ---
Both testcases from coment #0 and comment #2 now output with 4.8 and
trunk(4.9):
3 4
3 4
3 4
Assuming fixed.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2013-08-27 11:13 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-05-20 8:01 [Bug fortran/49076] New: ASSOCIATE: Array descriptor passed to explicit-shaped dummy burnus at gcc dot gnu.org
2011-05-20 22:15 ` [Bug fortran/49076] " burnus at gcc dot gnu.org
2011-05-21 4:17 ` andrew.t.baldwin at me dot com
2013-08-27 11:13 ` [Bug fortran/49076] [F03] " mikael at gcc dot gnu.org
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).