public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/29397] Problem with MAXLOC where mask involves a parameter array
2006-10-08 21:50 [Bug fortran/29397] New: Problem with MAXLOC where mask involves a parameter array fxcoudert at gcc dot gnu dot org
@ 2006-10-08 21:50 ` fxcoudert at gcc dot gnu dot org
2006-10-25 20:39 ` [Bug fortran/29397] Constant logical expression with " tkoenig at gcc dot gnu dot org
` (6 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: fxcoudert at gcc dot gnu dot org @ 2006-10-08 21:50 UTC (permalink / raw)
To: gcc-bugs
--
fxcoudert 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 |2006-10-08 21:50:42
date| |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29397
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug fortran/29397] New: Problem with MAXLOC where mask involves a parameter array
@ 2006-10-08 21:50 fxcoudert at gcc dot gnu dot org
2006-10-08 21:50 ` [Bug fortran/29397] " fxcoudert at gcc dot gnu dot org
` (7 more replies)
0 siblings, 8 replies; 9+ messages in thread
From: fxcoudert at gcc dot gnu dot org @ 2006-10-08 21:50 UTC (permalink / raw)
To: gcc-bugs
$ cat a8.f90
INTEGER :: K(3)=1
INTEGER, PARAMETER :: J(3)=2
write(6,*) MAXLOC(K,J<1)
END
$ gfortran a8.f90 && ./a.out
a.out: ../../../trunk/libgfortran/generated/maxloc0_4_i4.c:216: mmaxloc0_4_i4:
Assertion `((mask)->dtype >> 6) == 8' failed.
zsh: abort ./a.out
If the PARAMETER
--
Summary: Problem with MAXLOC where mask involves a parameter
array
Product: gcc
Version: 4.2.0
Status: UNCONFIRMED
Keywords: wrong-code
Severity: normal
Priority: P3
Component: fortran
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: fxcoudert at gcc dot gnu dot org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29397
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug fortran/29397] Constant logical expression with parameter array
2006-10-08 21:50 [Bug fortran/29397] New: Problem with MAXLOC where mask involves a parameter array fxcoudert at gcc dot gnu dot org
2006-10-08 21:50 ` [Bug fortran/29397] " fxcoudert at gcc dot gnu dot org
@ 2006-10-25 20:39 ` tkoenig at gcc dot gnu dot org
2007-02-06 14:05 ` fxcoudert at gcc dot gnu dot org
` (5 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: tkoenig at gcc dot gnu dot org @ 2006-10-25 20:39 UTC (permalink / raw)
To: gcc-bugs
------- Comment #1 from tkoenig at gcc dot gnu dot org 2006-10-25 20:39 -------
This is not a maxloc bug per se. Look at this:
$ cat a9.f90
INTEGER :: K(3)=1
INTEGER, PARAMETER :: J(3)=2
write (6,*) J<1
END
$ gfortran -fdump-tree-original a9.f90
$ ./a.out
F
Output should be
F F F
instead. This is correct when the logical expression
isn't constant:
$ cat a10.f90
INTEGER :: K(3)=1
INTEGER, PARAMETER :: J(3)= (/0, 1, 2 /)
write (6,*) J<1
END
$ gfortran a10.f90
$ ./a.out
T F F
Looks like overzelous simplification, somewhere.
--
tkoenig at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |tkoenig at gcc dot gnu dot
| |org
Summary|Problem with MAXLOC where |Constant logical expression
|mask involves a parameter |with parameter array
|array |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29397
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug fortran/29397] Constant logical expression with parameter array
2006-10-08 21:50 [Bug fortran/29397] New: Problem with MAXLOC where mask involves a parameter array fxcoudert at gcc dot gnu dot org
2006-10-08 21:50 ` [Bug fortran/29397] " fxcoudert at gcc dot gnu dot org
2006-10-25 20:39 ` [Bug fortran/29397] Constant logical expression with " tkoenig at gcc dot gnu dot org
@ 2007-02-06 14:05 ` fxcoudert at gcc dot gnu dot org
2007-02-09 22:42 ` fxcoudert at gcc dot gnu dot org
` (4 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: fxcoudert at gcc dot gnu dot org @ 2007-02-06 14:05 UTC (permalink / raw)
To: gcc-bugs
------- Comment #2 from fxcoudert at gcc dot gnu dot org 2007-02-06 14:05 -------
We're passing a pointer to a logical instead of an array descriptor:
$ cat a.f90
integer :: k(3), l(1)
integer, parameter :: j(3) = 2
l = maxloc (k, j<1)
end
$ cat a.f90.003t.original
MAIN__ ()
{
int4 l[1];
int4 k[3];
_gfortran_set_std (70, 127, 0, 0);
{
static logical4 C.1011 = 0;
struct array1_int4 parm.1;
struct array1_int4 parm.0;
parm.0.dtype = 265;
parm.0.dim[0].lbound = 1;
parm.0.dim[0].ubound = 1;
parm.0.dim[0].stride = 1;
parm.0.data = (void *) &l[0];
parm.0.offset = 0;
parm.1.dtype = 265;
parm.1.dim[0].lbound = 1;
parm.1.dim[0].ubound = 3;
parm.1.dim[0].stride = 1;
parm.1.data = (void *) &k[0];
parm.1.offset = 0;
_gfortran_mmaxloc0_4_i4 (&parm.0, &parm.1, &C.1011);
}
}
--
fxcoudert at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Last reconfirmed|2006-10-08 21:50:42 |2007-02-06 14:05:37
date| |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29397
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug fortran/29397] Constant logical expression with parameter array
2006-10-08 21:50 [Bug fortran/29397] New: Problem with MAXLOC where mask involves a parameter array fxcoudert at gcc dot gnu dot org
` (2 preceding siblings ...)
2007-02-06 14:05 ` fxcoudert at gcc dot gnu dot org
@ 2007-02-09 22:42 ` fxcoudert at gcc dot gnu dot org
2007-03-17 15:28 ` tkoenig at gcc dot gnu dot org
` (3 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: fxcoudert at gcc dot gnu dot org @ 2007-02-09 22:42 UTC (permalink / raw)
To: gcc-bugs
------- Comment #3 from fxcoudert at gcc dot gnu dot org 2007-02-09 22:42 -------
When we enter into gfc_trans_transfer, we have the following:
if (ss == gfc_ss_terminator)
{
/* Transfer a scalar value. */
and we come here with a EXPR_CONST array, for which ss is set to
gfc_ss_terminator, but it's not a scalar. It's pretty similar to PR29400, in a
different place of the front-end code. I don't know the translation of constant
arrays enough to understand if a temporary should be create there or earlier
(and where?).
--
fxcoudert at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Last reconfirmed|2007-02-06 14:05:37 |2007-02-09 22:42:15
date| |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29397
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug fortran/29397] Constant logical expression with parameter array
2006-10-08 21:50 [Bug fortran/29397] New: Problem with MAXLOC where mask involves a parameter array fxcoudert at gcc dot gnu dot org
` (3 preceding siblings ...)
2007-02-09 22:42 ` fxcoudert at gcc dot gnu dot org
@ 2007-03-17 15:28 ` tkoenig at gcc dot gnu dot org
2007-04-13 21:26 ` pault at gcc dot gnu dot org
` (2 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: tkoenig at gcc dot gnu dot org @ 2007-03-17 15:28 UTC (permalink / raw)
To: gcc-bugs
------- Comment #4 from tkoenig at gcc dot gnu dot org 2007-03-17 15:27 -------
*** Bug 31206 has been marked as a duplicate of this bug. ***
--
tkoenig at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |jv244 at cam dot ac dot uk
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29397
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug fortran/29397] Constant logical expression with parameter array
2006-10-08 21:50 [Bug fortran/29397] New: Problem with MAXLOC where mask involves a parameter array fxcoudert at gcc dot gnu dot org
` (4 preceding siblings ...)
2007-03-17 15:28 ` tkoenig at gcc dot gnu dot org
@ 2007-04-13 21:26 ` pault at gcc dot gnu dot org
2007-04-13 22:25 ` pault at gcc dot gnu dot org
2007-05-07 4:44 ` pault at gcc dot gnu dot org
7 siblings, 0 replies; 9+ messages in thread
From: pault at gcc dot gnu dot org @ 2007-04-13 21:26 UTC (permalink / raw)
To: gcc-bugs
------- Comment #5 from pault at gcc dot gnu dot org 2007-04-13 22:26 -------
INTEGER :: K(3)=1
INTEGER, PARAMETER :: J(3)=(/1,2,0/)
write(6,*) MAXLOC(K,J<1)
END
works just fine. I would say that the problem is that the initializtion
expression is never getting turned into an EXPR_ARRAY.
Paul
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29397
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug fortran/29397] Constant logical expression with parameter array
2006-10-08 21:50 [Bug fortran/29397] New: Problem with MAXLOC where mask involves a parameter array fxcoudert at gcc dot gnu dot org
` (5 preceding siblings ...)
2007-04-13 21:26 ` pault at gcc dot gnu dot org
@ 2007-04-13 22:25 ` pault at gcc dot gnu dot org
2007-05-07 4:44 ` pault at gcc dot gnu dot org
7 siblings, 0 replies; 9+ messages in thread
From: pault at gcc dot gnu dot org @ 2007-04-13 22:25 UTC (permalink / raw)
To: gcc-bugs
------- Comment #6 from pault at gcc dot gnu dot org 2007-04-13 23:24 -------
This cures the problem but is otherwise untested.
Paul
Index: gcc/fortran/decl.c
===================================================================
*** gcc/fortran/decl.c (revision 123793)
--- gcc/fortran/decl.c (working copy)
*************** add_init_expr_to_sym (const char *name,
*** 972,978 ****
/* Add initializer. Make sure we keep the ranks sane. */
if (sym->attr.dimension && init->rank == 0)
! init->rank = sym->as->rank;
sym->value = init;
*initp = NULL;
--- 972,1001 ----
/* Add initializer. Make sure we keep the ranks sane. */
if (sym->attr.dimension && init->rank == 0)
! {
! mpz_t size;
! gfc_constructor *ctor, *tail;
! int n;
! if (sym->attr.flavor == FL_PARAMETER
! && init->expr_type == EXPR_CONSTANT)
! {
! spec_size (sym->as, &size);
! ctor = tail = gfc_get_constructor ();
! ctor->expr = init;
! for (n = 1; n < (int)mpz_get_si (size); n++)
! {
! tail->next = gfc_get_constructor ();
! tail = tail->next;
! tail->expr = gfc_copy_expr (init);
! }
! init = gfc_get_expr ();
! init->expr_type = EXPR_ARRAY;
! init->ts = ctor->expr->ts;
! init->value.constructor = ctor;
! mpz_clear (size);
! }
! init->rank = sym->as->rank;
! }
sym->value = init;
*initp = NULL;
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29397
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug fortran/29397] Constant logical expression with parameter array
2006-10-08 21:50 [Bug fortran/29397] New: Problem with MAXLOC where mask involves a parameter array fxcoudert at gcc dot gnu dot org
` (6 preceding siblings ...)
2007-04-13 22:25 ` pault at gcc dot gnu dot org
@ 2007-05-07 4:44 ` pault at gcc dot gnu dot org
7 siblings, 0 replies; 9+ messages in thread
From: pault at gcc dot gnu dot org @ 2007-05-07 4:44 UTC (permalink / raw)
To: gcc-bugs
------- Comment #7 from pault at gcc dot gnu dot org 2007-05-07 05:44 -------
The patch below works and regtests. Before submitting it, however, I would
like to understand why I could not persuade the use of the repeat count to
work, rather than expanding to a full array.
Paul
Index: gcc/fortran/decl.c
===================================================================
*** gcc/fortran/decl.c (revision 124474)
--- gcc/fortran/decl.c (working copy)
*************** add_init_expr_to_sym (const char *name,
*** 974,980 ****
/* Add initializer. Make sure we keep the ranks sane. */
if (sym->attr.dimension && init->rank == 0)
! init->rank = sym->as->rank;
sym->value = init;
*initp = NULL;
--- 974,1004 ----
/* Add initializer. Make sure we keep the ranks sane. */
if (sym->attr.dimension && init->rank == 0)
! {
! mpz_t size;
! gfc_constructor *ctor, *tail;
! int n;
! if (sym->attr.flavor == FL_PARAMETER
! && init->expr_type == EXPR_CONSTANT
! && spec_size (sym->as, &size) == SUCCESS
! && mpz_cmp_si (size, 0) > 0)
! {
! ctor = tail = gfc_get_constructor ();
! ctor->expr = init;
! for (n = 1; n < (int)mpz_get_si (size); n++)
! {
! tail->next = gfc_get_constructor ();
! tail = tail->next;
! tail->expr = gfc_copy_expr (init);
! }
! init = gfc_get_expr ();
! init->expr_type = EXPR_ARRAY;
! init->ts = ctor->expr->ts;
! init->value.constructor = ctor;
! mpz_clear (size);
! }
! init->rank = sym->as->rank;
! }
sym->value = init;
*initp = NULL;
Index: gcc/testsuite/gfortran.dg/parameter_array_init_1.f90
===================================================================
*** gcc/testsuite/gfortran.dg/parameter_array_init_1.f90 (revision 0)
--- gcc/testsuite/gfortran.dg/parameter_array_init_1.f90 (revision 0)
***************
*** 0 ****
--- 1,11 ----
+ ! { dg-do compile }
+ ! tests the fix for PR29397, in which the initializer for the parameter
+ ! 'J' was not expanded into an array.
+ !
+ ! Contributed by Francois-Xavier Coudert <fxcoudert@gcc.gnu.org>
+ !
+ INTEGER :: K(3) = 1
+ INTEGER, PARAMETER :: J(3) = 2
+ IF (ANY (MAXLOC (K, J<3) .NE. 1)) CALL ABORT ()
+ IF (ANY (J .NE. 2)) CALL ABORT ()
+ END
--
pault at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
AssignedTo|unassigned at gcc dot gnu |pault at gcc dot gnu dot org
|dot org |
Status|NEW |ASSIGNED
Last reconfirmed|2007-02-09 22:42:15 |2007-05-07 05:44:48
date| |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29397
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2007-05-07 4:44 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-10-08 21:50 [Bug fortran/29397] New: Problem with MAXLOC where mask involves a parameter array fxcoudert at gcc dot gnu dot org
2006-10-08 21:50 ` [Bug fortran/29397] " fxcoudert at gcc dot gnu dot org
2006-10-25 20:39 ` [Bug fortran/29397] Constant logical expression with " tkoenig at gcc dot gnu dot org
2007-02-06 14:05 ` fxcoudert at gcc dot gnu dot org
2007-02-09 22:42 ` fxcoudert at gcc dot gnu dot org
2007-03-17 15:28 ` tkoenig at gcc dot gnu dot org
2007-04-13 21:26 ` pault at gcc dot gnu dot org
2007-04-13 22:25 ` pault at gcc dot gnu dot org
2007-05-07 4:44 ` 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).