public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/30865] New: optional argument passed on to size(...,dim=)
@ 2007-02-19 22:14 tkoenig at gcc dot gnu dot org
2007-02-20 5:34 ` [Bug fortran/30865] " pault at gcc dot gnu dot org
` (15 more replies)
0 siblings, 16 replies; 17+ messages in thread
From: tkoenig at gcc dot gnu dot org @ 2007-02-19 22:14 UTC (permalink / raw)
To: gcc-bugs
The following is legal (see
<7dpCh.29496$5j1.2977@bgtnsc04-news.ops.worldnet.att.net>), but we segfault
on execution:
$ cat size.f90
module foo
contains
subroutine checkv(ires,a1,opt1)
integer :: a1(:,:)
integer, optional :: opt1
ires = size (a1, dim=opt1)
end subroutine checkv
end module foo
program main
use foo
implicit none
integer :: a(2,3)
integer :: ires
call checkv (ires, a)
print *,ires
call checkv (ires, a, 1)
print *,ires
end program main
$ gfortran size.f90
$ ./a.out
Segmentation fault
--
Summary: optional argument passed on to size(...,dim=)
Product: gcc
Version: 4.3.0
Status: UNCONFIRMED
Keywords: wrong-code
Severity: normal
Priority: P3
Component: fortran
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: tkoenig at gcc dot gnu dot org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=30865
^ permalink raw reply [flat|nested] 17+ messages in thread
* [Bug fortran/30865] optional argument passed on to size(...,dim=)
2007-02-19 22:14 [Bug fortran/30865] New: optional argument passed on to size(...,dim=) tkoenig at gcc dot gnu dot org
@ 2007-02-20 5:34 ` pault at gcc dot gnu dot org
2007-02-20 5:35 ` pault at gcc dot gnu dot org
` (14 subsequent siblings)
15 siblings, 0 replies; 17+ messages in thread
From: pault at gcc dot gnu dot org @ 2007-02-20 5:34 UTC (permalink / raw)
To: gcc-bugs
------- Comment #1 from pault at gcc dot gnu dot org 2007-02-20 05:34 -------
Confirmed:
The first call to checkv produces
checkv (&ires, &parm.10, 0B);
With prototype: checkv (ires, a1, opt1), the call to size1 is
*ires = _gfortran_size1 (&parm.6, *opt1);
with the obvious consequences.
Paul
As an aside, Thomas, it seems to me that the fix is relatively easy:
trans-intrinsic.c:2702
actual = actual->next;
if (actual->expr)
{
gfc_init_se (&argse, NULL);
gfc_conv_expr_type (&argse, actual->expr, gfc_array_index_type);
gfc_add_block_to_block (&se->pre, &argse.pre);
args = gfc_chainon_list (args, argse.expr);
fndecl = gfor_fndecl_size1;
}
else
fndecl = gfor_fndecl_size0;
We need a tree conditional that effects this:
fndecl = argse.pre == 0B ? gfor_fndecl_size0 : gfor_fndecl_size1
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=30865
^ permalink raw reply [flat|nested] 17+ messages in thread
* [Bug fortran/30865] optional argument passed on to size(...,dim=)
2007-02-19 22:14 [Bug fortran/30865] New: optional argument passed on to size(...,dim=) tkoenig at gcc dot gnu dot org
2007-02-20 5:34 ` [Bug fortran/30865] " pault at gcc dot gnu dot org
@ 2007-02-20 5:35 ` pault at gcc dot gnu dot org
2007-02-20 8:57 ` burnus at gcc dot gnu dot org
` (13 subsequent siblings)
15 siblings, 0 replies; 17+ messages in thread
From: pault at gcc dot gnu dot org @ 2007-02-20 5:35 UTC (permalink / raw)
To: gcc-bugs
--
pault at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Ever Confirmed|0 |1
Last reconfirmed|0000-00-00 00:00:00 |2007-02-20 05:35:18
date| |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=30865
^ permalink raw reply [flat|nested] 17+ messages in thread
* [Bug fortran/30865] optional argument passed on to size(...,dim=)
2007-02-19 22:14 [Bug fortran/30865] New: optional argument passed on to size(...,dim=) tkoenig at gcc dot gnu dot org
2007-02-20 5:34 ` [Bug fortran/30865] " pault at gcc dot gnu dot org
2007-02-20 5:35 ` pault at gcc dot gnu dot org
@ 2007-02-20 8:57 ` burnus at gcc dot gnu dot org
2007-02-20 13:16 ` burnus at gcc dot gnu dot org
` (12 subsequent siblings)
15 siblings, 0 replies; 17+ messages in thread
From: burnus at gcc dot gnu dot org @ 2007-02-20 8:57 UTC (permalink / raw)
To: gcc-bugs
------- Comment #2 from burnus at gcc dot gnu dot org 2007-02-20 08:57 -------
> The following is legal but we segfault on execution:
> subroutine checkv(ires,a1,opt1)
> integer :: a1(:,:)
> integer, optional :: opt1
> ires = size (a1, dim=opt1)
For those who wonder (as I did) why using an optional argument is legal:
It is only used as actual argument corresponding to an optional dummy argument.
(cf. 12.4.1.6 in the Fortran 2003 standard).
--
burnus at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |burnus at gcc dot gnu dot
| |org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=30865
^ permalink raw reply [flat|nested] 17+ messages in thread
* [Bug fortran/30865] optional argument passed on to size(...,dim=)
2007-02-19 22:14 [Bug fortran/30865] New: optional argument passed on to size(...,dim=) tkoenig at gcc dot gnu dot org
` (2 preceding siblings ...)
2007-02-20 8:57 ` burnus at gcc dot gnu dot org
@ 2007-02-20 13:16 ` burnus at gcc dot gnu dot org
2007-02-20 14:35 ` pault at gcc dot gnu dot org
` (11 subsequent siblings)
15 siblings, 0 replies; 17+ messages in thread
From: burnus at gcc dot gnu dot org @ 2007-02-20 13:16 UTC (permalink / raw)
To: gcc-bugs
------- Comment #3 from burnus at gcc dot gnu dot org 2007-02-20 13:16 -------
(In reply to comment #2)
> For those who wonder (as I did) why using an optional argument is legal:
> It is only used as actual argument corresponding to an optional dummy
> argument. (cf. 12.4.1.6 in the Fortran 2003 standard).
And on the fact that the optional argument does not change the rank.
This PR is seemingly based on the following c.l.fortran thread:
http://groups.google.com/group/comp.lang.fortran/browse_thread/thread/1e7a4db9d998955a
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=30865
^ permalink raw reply [flat|nested] 17+ messages in thread
* [Bug fortran/30865] optional argument passed on to size(...,dim=)
2007-02-19 22:14 [Bug fortran/30865] New: optional argument passed on to size(...,dim=) tkoenig at gcc dot gnu dot org
` (3 preceding siblings ...)
2007-02-20 13:16 ` burnus at gcc dot gnu dot org
@ 2007-02-20 14:35 ` pault at gcc dot gnu dot org
2007-02-20 14:39 ` pault at gcc dot gnu dot org
` (10 subsequent siblings)
15 siblings, 0 replies; 17+ messages in thread
From: pault at gcc dot gnu dot org @ 2007-02-20 14:35 UTC (permalink / raw)
To: gcc-bugs
------- Comment #4 from pault at gcc dot gnu dot org 2007-02-20 14:35 -------
Created an attachment (id=13073)
--> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=13073&action=view)
Fix for the problem
I will set this regtesting in a few minutes and will post the result. Note,
however, that I can do nothing with this for a few weeks. Therefore if one of
you want to bring it forth to the commit stage, please be my guest; note that
the code could be tidied up and the testcase needs dejagnufying.
Paul
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=30865
^ permalink raw reply [flat|nested] 17+ messages in thread
* [Bug fortran/30865] optional argument passed on to size(...,dim=)
2007-02-19 22:14 [Bug fortran/30865] New: optional argument passed on to size(...,dim=) tkoenig at gcc dot gnu dot org
` (4 preceding siblings ...)
2007-02-20 14:35 ` pault at gcc dot gnu dot org
@ 2007-02-20 14:39 ` pault at gcc dot gnu dot org
2007-02-20 17:25 ` pault at gcc dot gnu dot org
` (9 subsequent siblings)
15 siblings, 0 replies; 17+ messages in thread
From: pault at gcc dot gnu dot org @ 2007-02-20 14:39 UTC (permalink / raw)
To: gcc-bugs
------- Comment #5 from pault at gcc dot gnu dot org 2007-02-20 14:39 -------
(In reply to comment #4)
> Created an attachment (id=13073)
--> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=13073&action=view) [edit]
> Fix for the problem
I should have remarked that the patch produces the following code:
D.1015 = &parm.6;
D.1016 = (void *) opt1 != 0B;
*ires = D.1016 ? _gfortran_size1 (D.1015, *opt1) : _gfortran_size0
(D.1015);
Paul
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=30865
^ permalink raw reply [flat|nested] 17+ messages in thread
* [Bug fortran/30865] optional argument passed on to size(...,dim=)
2007-02-19 22:14 [Bug fortran/30865] New: optional argument passed on to size(...,dim=) tkoenig at gcc dot gnu dot org
` (5 preceding siblings ...)
2007-02-20 14:39 ` pault at gcc dot gnu dot org
@ 2007-02-20 17:25 ` pault at gcc dot gnu dot org
2007-02-21 19:02 ` kargl at gcc dot gnu dot org
` (8 subsequent siblings)
15 siblings, 0 replies; 17+ messages in thread
From: pault at gcc dot gnu dot org @ 2007-02-20 17:25 UTC (permalink / raw)
To: gcc-bugs
------- Comment #6 from pault at gcc dot gnu dot org 2007-02-20 17:25 -------
(In reply to comment #5)
> (In reply to comment #4)
> > Created an attachment (id=13073)
--> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=13073&action=view) [edit]
> > Fix for the problem
> I should have remarked that the patch produces the following code:
..and it regests and bootstraps on Cygwin_NT/i686
Paul
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=30865
^ permalink raw reply [flat|nested] 17+ messages in thread
* [Bug fortran/30865] optional argument passed on to size(...,dim=)
2007-02-19 22:14 [Bug fortran/30865] New: optional argument passed on to size(...,dim=) tkoenig at gcc dot gnu dot org
` (6 preceding siblings ...)
2007-02-20 17:25 ` pault at gcc dot gnu dot org
@ 2007-02-21 19:02 ` kargl at gcc dot gnu dot org
2007-02-24 21:48 ` tkoenig at gcc dot gnu dot org
` (7 subsequent siblings)
15 siblings, 0 replies; 17+ messages in thread
From: kargl at gcc dot gnu dot org @ 2007-02-21 19:02 UTC (permalink / raw)
To: gcc-bugs
------- Comment #7 from kargl at gcc dot gnu dot org 2007-02-21 19:02 -------
(In reply to comment #4)
> Created an attachment (id=13073)
--> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=13073&action=view) [edit]
> Fix for the problem
>
Paul, I tried to apply your patch, but it is rejected. Is your
code up-to-date? In particular, Sandra'a recent CALL_EXPR patch caused
a lot of code churn in trans-*.c files.
steve
--
kargl at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |kargl at gcc dot gnu dot org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=30865
^ permalink raw reply [flat|nested] 17+ messages in thread
* [Bug fortran/30865] optional argument passed on to size(...,dim=)
2007-02-19 22:14 [Bug fortran/30865] New: optional argument passed on to size(...,dim=) tkoenig at gcc dot gnu dot org
` (7 preceding siblings ...)
2007-02-21 19:02 ` kargl at gcc dot gnu dot org
@ 2007-02-24 21:48 ` tkoenig at gcc dot gnu dot org
2007-02-25 2:46 ` patchapp at dberlin dot org
` (6 subsequent siblings)
15 siblings, 0 replies; 17+ messages in thread
From: tkoenig at gcc dot gnu dot org @ 2007-02-24 21:48 UTC (permalink / raw)
To: gcc-bugs
------- Comment #8 from tkoenig at gcc dot gnu dot org 2007-02-24 21:48 -------
(In reply to comment #7)
> Paul, I tried to apply your patch, but it is rejected.
I applied the patch with a recent trunk, which worked (except
I got a message that the patch file contained CR/LF).
I'm running a regression-test now.
Thomas
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=30865
^ permalink raw reply [flat|nested] 17+ messages in thread
* [Bug fortran/30865] optional argument passed on to size(...,dim=)
2007-02-19 22:14 [Bug fortran/30865] New: optional argument passed on to size(...,dim=) tkoenig at gcc dot gnu dot org
` (8 preceding siblings ...)
2007-02-24 21:48 ` tkoenig at gcc dot gnu dot org
@ 2007-02-25 2:46 ` patchapp at dberlin dot org
2007-02-26 21:16 ` tkoenig at gcc dot gnu dot org
` (5 subsequent siblings)
15 siblings, 0 replies; 17+ messages in thread
From: patchapp at dberlin dot org @ 2007-02-25 2:46 UTC (permalink / raw)
To: gcc-bugs
------- Comment #9 from patchapp at dberlin dot org 2007-02-25 02:46 -------
Subject: Bug number PR 30865
A patch for this bug has been added to the patch tracker.
The mailing list url for the patch is
http://gcc.gnu.org/ml/gcc-patches/2007-02/msg01956.html
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=30865
^ permalink raw reply [flat|nested] 17+ messages in thread
* [Bug fortran/30865] optional argument passed on to size(...,dim=)
2007-02-19 22:14 [Bug fortran/30865] New: optional argument passed on to size(...,dim=) tkoenig at gcc dot gnu dot org
` (9 preceding siblings ...)
2007-02-25 2:46 ` patchapp at dberlin dot org
@ 2007-02-26 21:16 ` tkoenig at gcc dot gnu dot org
2007-02-26 22:00 ` [Bug fortran/30865] [4.1, 4.2 only] " burnus at gcc dot gnu dot org
` (4 subsequent siblings)
15 siblings, 0 replies; 17+ messages in thread
From: tkoenig at gcc dot gnu dot org @ 2007-02-26 21:16 UTC (permalink / raw)
To: gcc-bugs
------- Comment #10 from tkoenig at gcc dot gnu dot org 2007-02-26 21:16 -------
Subject: Bug 30865
Author: tkoenig
Date: Mon Feb 26 21:16:00 2007
New Revision: 122342
URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=122342
Log:
2007-02-26 Thomas Koenig <Thomas.Koenig@online.de>
Paul Thomas <pault@gcc.gnu.org>
PR fortran/30865
* trans-intrinsic.c (gfc_conv_intrinsic_size):
If dim is an optional argument, check for its
presence and call size0 or size1, respectively.
2007-02-26 Thomas Koenig <Thomas.Koenig@online.de>
PR fortran/30865
* size_optional_dim_1.f90: New test.
Added:
trunk/gcc/testsuite/gfortran.dg/size_optional_dim_1.f90
Modified:
trunk/gcc/fortran/ChangeLog
trunk/gcc/fortran/trans-intrinsic.c
trunk/gcc/testsuite/ChangeLog
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=30865
^ permalink raw reply [flat|nested] 17+ messages in thread
* [Bug fortran/30865] [4.1, 4.2 only] optional argument passed on to size(...,dim=)
2007-02-19 22:14 [Bug fortran/30865] New: optional argument passed on to size(...,dim=) tkoenig at gcc dot gnu dot org
` (10 preceding siblings ...)
2007-02-26 21:16 ` tkoenig at gcc dot gnu dot org
@ 2007-02-26 22:00 ` burnus at gcc dot gnu dot org
2007-02-27 17:46 ` burnus at gcc dot gnu dot org
` (3 subsequent siblings)
15 siblings, 0 replies; 17+ messages in thread
From: burnus at gcc dot gnu dot org @ 2007-02-26 22:00 UTC (permalink / raw)
To: gcc-bugs
--
burnus at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
AssignedTo|unassigned at gcc dot gnu |tkoenig at gcc dot gnu dot
|dot org |org
Status|NEW |ASSIGNED
Summary|optional argument passed on |[4.1, 4.2 only] optional
|to size(...,dim=) |argument passed on to
| |size(...,dim=)
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=30865
^ permalink raw reply [flat|nested] 17+ messages in thread
* [Bug fortran/30865] [4.1, 4.2 only] optional argument passed on to size(...,dim=)
2007-02-19 22:14 [Bug fortran/30865] New: optional argument passed on to size(...,dim=) tkoenig at gcc dot gnu dot org
` (11 preceding siblings ...)
2007-02-26 22:00 ` [Bug fortran/30865] [4.1, 4.2 only] " burnus at gcc dot gnu dot org
@ 2007-02-27 17:46 ` burnus at gcc dot gnu dot org
2007-02-28 11:28 ` burnus at gcc dot gnu dot org
` (2 subsequent siblings)
15 siblings, 0 replies; 17+ messages in thread
From: burnus at gcc dot gnu dot org @ 2007-02-27 17:46 UTC (permalink / raw)
To: gcc-bugs
------- Comment #11 from burnus at gcc dot gnu dot org 2007-02-27 17:46 -------
The following additional patch needs to be applied when backporting:
http://gcc.gnu.org/ml/fortran/2007-02/msg00620.html
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=30865
^ permalink raw reply [flat|nested] 17+ messages in thread
* [Bug fortran/30865] [4.1, 4.2 only] optional argument passed on to size(...,dim=)
2007-02-19 22:14 [Bug fortran/30865] New: optional argument passed on to size(...,dim=) tkoenig at gcc dot gnu dot org
` (12 preceding siblings ...)
2007-02-27 17:46 ` burnus at gcc dot gnu dot org
@ 2007-02-28 11:28 ` burnus at gcc dot gnu dot org
2007-03-01 8:19 ` burnus at gcc dot gnu dot org
2007-03-27 8:59 ` pault at gcc dot gnu dot org
15 siblings, 0 replies; 17+ messages in thread
From: burnus at gcc dot gnu dot org @ 2007-02-28 11:28 UTC (permalink / raw)
To: gcc-bugs
------- Comment #12 from burnus at gcc dot gnu dot org 2007-02-28 11:28 -------
> The following additional patch needs to be applied when backporting:
> http://gcc.gnu.org/ml/fortran/2007-02/msg00620.html
This two-line patch is unrelated.
(I think one should nonetheless backport it to 4.2 [is not in 4.1].)
The following is the real patch:
http://gcc.gnu.org/ml/gcc-patches/2007-02/msg02200.html
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=30865
^ permalink raw reply [flat|nested] 17+ messages in thread
* [Bug fortran/30865] [4.1, 4.2 only] optional argument passed on to size(...,dim=)
2007-02-19 22:14 [Bug fortran/30865] New: optional argument passed on to size(...,dim=) tkoenig at gcc dot gnu dot org
` (13 preceding siblings ...)
2007-02-28 11:28 ` burnus at gcc dot gnu dot org
@ 2007-03-01 8:19 ` burnus at gcc dot gnu dot org
2007-03-27 8:59 ` pault at gcc dot gnu dot org
15 siblings, 0 replies; 17+ messages in thread
From: burnus at gcc dot gnu dot org @ 2007-03-01 8:19 UTC (permalink / raw)
To: gcc-bugs
------- Comment #13 from burnus at gcc dot gnu dot org 2007-03-01 08:19 -------
Subject: Bug 30865
Author: burnus
Date: Thu Mar 1 08:19:09 2007
New Revision: 122423
URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=122423
Log:
2007-03-01 Tobias Burnus <burnus@net-b.de>
PR fortran/30865
* trans-intrinsic.c (gfc_conv_intrinsic_size): Compare pointers.
Modified:
trunk/gcc/fortran/ChangeLog
trunk/gcc/fortran/trans-intrinsic.c
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=30865
^ permalink raw reply [flat|nested] 17+ messages in thread
* [Bug fortran/30865] [4.1, 4.2 only] optional argument passed on to size(...,dim=)
2007-02-19 22:14 [Bug fortran/30865] New: optional argument passed on to size(...,dim=) tkoenig at gcc dot gnu dot org
` (14 preceding siblings ...)
2007-03-01 8:19 ` burnus at gcc dot gnu dot org
@ 2007-03-27 8:59 ` pault at gcc dot gnu dot org
15 siblings, 0 replies; 17+ messages in thread
From: pault at gcc dot gnu dot org @ 2007-03-27 8:59 UTC (permalink / raw)
To: gcc-bugs
------- Comment #14 from pault at gcc dot gnu dot org 2007-03-27 09:59 -------
Not a regression from 4.1, so closing.
Paul
--
pault at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|ASSIGNED |RESOLVED
Resolution| |FIXED
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=30865
^ permalink raw reply [flat|nested] 17+ messages in thread
end of thread, other threads:[~2007-03-27 8:59 UTC | newest]
Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-02-19 22:14 [Bug fortran/30865] New: optional argument passed on to size(...,dim=) tkoenig at gcc dot gnu dot org
2007-02-20 5:34 ` [Bug fortran/30865] " pault at gcc dot gnu dot org
2007-02-20 5:35 ` pault at gcc dot gnu dot org
2007-02-20 8:57 ` burnus at gcc dot gnu dot org
2007-02-20 13:16 ` burnus at gcc dot gnu dot org
2007-02-20 14:35 ` pault at gcc dot gnu dot org
2007-02-20 14:39 ` pault at gcc dot gnu dot org
2007-02-20 17:25 ` pault at gcc dot gnu dot org
2007-02-21 19:02 ` kargl at gcc dot gnu dot org
2007-02-24 21:48 ` tkoenig at gcc dot gnu dot org
2007-02-25 2:46 ` patchapp at dberlin dot org
2007-02-26 21:16 ` tkoenig at gcc dot gnu dot org
2007-02-26 22:00 ` [Bug fortran/30865] [4.1, 4.2 only] " burnus at gcc dot gnu dot org
2007-02-27 17:46 ` burnus at gcc dot gnu dot org
2007-02-28 11:28 ` burnus at gcc dot gnu dot org
2007-03-01 8:19 ` burnus at gcc dot gnu dot org
2007-03-27 8:59 ` pault at gcc dot gnu dot 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).