public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/56849] New: Missing compile-time shape check for RESHAPE assignments
@ 2013-04-05 19:03 burnus at gcc dot gnu.org
  2013-04-05 20:02 ` [Bug fortran/56849] " dominiq at lps dot ens.fr
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: burnus at gcc dot gnu.org @ 2013-04-05 19:03 UTC (permalink / raw)
  To: gcc-bugs


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56849

             Bug #: 56849
           Summary: Missing compile-time shape check for RESHAPE
                    assignments
    Classification: Unclassified
           Product: gcc
           Version: 4.9.0
            Status: UNCONFIRMED
          Keywords: accepts-invalid, diagnostic
          Severity: normal
          Priority: P3
         Component: fortran
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: burnus@gcc.gnu.org


The following code is invalid as one assigns a [1,2] array to a [2,1] variable.

NAG properly diagnoses this at compile time:
Error: test.f90, line 3: Array shapes differ in dimension 1 (extent 2 and 1)

gfortran doesn't but fails at runtime:
Fortran runtime error: shape and target do not conform


integer :: x(2,2),y(4)
y = reshape([1,2,3,4],[4])
x(:,1:1) = reshape(y(::2), [1,2])
print *, y
print *, x(:,1)
end


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug fortran/56849] Missing compile-time shape check for RESHAPE assignments
  2013-04-05 19:03 [Bug fortran/56849] New: Missing compile-time shape check for RESHAPE assignments burnus at gcc dot gnu.org
@ 2013-04-05 20:02 ` dominiq at lps dot ens.fr
  2013-04-05 20:18 ` burnus at gcc dot gnu.org
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: dominiq at lps dot ens.fr @ 2013-04-05 20:02 UTC (permalink / raw)
  To: gcc-bugs


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56849

--- Comment #1 from Dominique d'Humieres <dominiq at lps dot ens.fr> 2013-04-05 20:02:31 UTC ---
On x86_64-apple-darwin10, I get

 pr56849.f90:3:

x(:,1:1) = reshape(y(::2), [1,2])
1
Error: Different shape for array assignment at (1) on dimension 1 (2 and 1)

for all the versions I have tested from 4.4.6 to a clean 4.9.0 at r197238.


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug fortran/56849] Missing compile-time shape check for RESHAPE assignments
  2013-04-05 19:03 [Bug fortran/56849] New: Missing compile-time shape check for RESHAPE assignments burnus at gcc dot gnu.org
  2013-04-05 20:02 ` [Bug fortran/56849] " dominiq at lps dot ens.fr
@ 2013-04-05 20:18 ` burnus at gcc dot gnu.org
  2013-04-05 20:25 ` [Bug fortran/56849] Missing compile-time shape check for RESHAPE assignments with an ORDER= attribute dominiq at lps dot ens.fr
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: burnus at gcc dot gnu.org @ 2013-04-05 20:18 UTC (permalink / raw)
  To: gcc-bugs


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56849

Tobias Burnus <burnus at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |burnus at gcc dot gnu.org

--- Comment #2 from Tobias Burnus <burnus at gcc dot gnu.org> 2013-04-05 20:18:10 UTC ---
Pilot error - I though I had tested that version, but seemingly I didn't. I
encountered it with an ORDER= attribute - without ORDER= the warning is
printed.

integer :: x(2,2),y(4)
y = reshape([1,2,3,4],[4])
x(:,1:1) = reshape(y(::2), [1,2], order=[1,2])
print *, y
print *, x(:,1)
end


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug fortran/56849] Missing compile-time shape check for RESHAPE assignments with an ORDER= attribute
  2013-04-05 19:03 [Bug fortran/56849] New: Missing compile-time shape check for RESHAPE assignments burnus at gcc dot gnu.org
  2013-04-05 20:02 ` [Bug fortran/56849] " dominiq at lps dot ens.fr
  2013-04-05 20:18 ` burnus at gcc dot gnu.org
@ 2013-04-05 20:25 ` dominiq at lps dot ens.fr
  2013-04-05 20:38 ` burnus at gcc dot gnu.org
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: dominiq at lps dot ens.fr @ 2013-04-05 20:25 UTC (permalink / raw)
  To: gcc-bugs


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56849

Dominique d'Humieres <dominiq at lps dot ens.fr> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2013-04-05
            Summary|Missing compile-time shape  |Missing compile-time shape
                   |check for RESHAPE           |check for RESHAPE
                   |assignments                 |assignments with an ORDER=
                   |                            |attribute
     Ever Confirmed|0                           |1

--- Comment #3 from Dominique d'Humieres <dominiq at lps dot ens.fr> 2013-04-05 20:25:45 UTC ---
Confirmed for the test in comment #2 from 4.3.1 to trunk.


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug fortran/56849] Missing compile-time shape check for RESHAPE assignments with an ORDER= attribute
  2013-04-05 19:03 [Bug fortran/56849] New: Missing compile-time shape check for RESHAPE assignments burnus at gcc dot gnu.org
                   ` (2 preceding siblings ...)
  2013-04-05 20:25 ` [Bug fortran/56849] Missing compile-time shape check for RESHAPE assignments with an ORDER= attribute dominiq at lps dot ens.fr
@ 2013-04-05 20:38 ` burnus at gcc dot gnu.org
  2013-04-08 20:13 ` burnus at gcc dot gnu.org
  2013-04-08 20:14 ` burnus at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: burnus at gcc dot gnu.org @ 2013-04-05 20:38 UTC (permalink / raw)
  To: gcc-bugs


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56849

--- Comment #4 from Tobias Burnus <burnus at gcc dot gnu.org> 2013-04-05 20:38:05 UTC ---
Seems as if someone missed the purpose of ORDER=, which doesn't affect the
shape:

print *, shape (reshape([1,2,3,4,5,6], [2,3], order=[1,2]))
print *, shape (reshape([1,2,3,4,5,6], [2,3], order=[2,1]))
print *, reshape([1,2,3,4,5,6], [2,3], order=[1,2])
print *, reshape([1,2,3,4,5,6], [2,3], order=[2,1])
end

prints:
 2 3
 2 3
 1 2 3 4 5 6
 1 4 2 5 3 6


>From gfc_resolve_reshape. The "order == NULL" check is wrong:

  /* TODO: Make this work with a constant ORDER parameter.  */
  if (shape->expr_type == EXPR_ARRAY
      && gfc_is_constant_expr (shape)
      && order == NULL)
    {
      gfc_constructor *c;
      f->shape = gfc_get_shape (f->rank);


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug fortran/56849] Missing compile-time shape check for RESHAPE assignments with an ORDER= attribute
  2013-04-05 19:03 [Bug fortran/56849] New: Missing compile-time shape check for RESHAPE assignments burnus at gcc dot gnu.org
                   ` (3 preceding siblings ...)
  2013-04-05 20:38 ` burnus at gcc dot gnu.org
@ 2013-04-08 20:13 ` burnus at gcc dot gnu.org
  2013-04-08 20:14 ` burnus at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: burnus at gcc dot gnu.org @ 2013-04-08 20:13 UTC (permalink / raw)
  To: gcc-bugs


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56849

--- Comment #5 from Tobias Burnus <burnus at gcc dot gnu.org> 2013-04-08 20:13:47 UTC ---
Author: burnus
Date: Sun Apr  7 08:41:17 2013
New Revision: 197550

URL: http://gcc.gnu.org/viewcvs?rev=197550&root=gcc&view=rev
Log:
2013-04-07  Tobias Burnus  <burnus@net-b.de>

        PR fortran/56849
        * iresolve.c (gfc_resolve_reshape): Set shape also
        with order=.

2013-04-07  Tobias Burnus  <burnus@net-b.de>

        PR fortran/56849
        * gfortran.dg/reshape_5.f90: New.


Added:
    trunk/gcc/testsuite/gfortran.dg/reshape_5.f90
Modified:
    trunk/gcc/fortran/ChangeLog
    trunk/gcc/fortran/iresolve.c
    trunk/gcc/testsuite/ChangeLog


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug fortran/56849] Missing compile-time shape check for RESHAPE assignments with an ORDER= attribute
  2013-04-05 19:03 [Bug fortran/56849] New: Missing compile-time shape check for RESHAPE assignments burnus at gcc dot gnu.org
                   ` (4 preceding siblings ...)
  2013-04-08 20:13 ` burnus at gcc dot gnu.org
@ 2013-04-08 20:14 ` burnus at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: burnus at gcc dot gnu.org @ 2013-04-08 20:14 UTC (permalink / raw)
  To: gcc-bugs


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56849

Tobias Burnus <burnus at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED

--- Comment #6 from Tobias Burnus <burnus at gcc dot gnu.org> 2013-04-08 20:14:07 UTC ---
FIXED on the 4.9 trunk.


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2013-04-08 20:14 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-04-05 19:03 [Bug fortran/56849] New: Missing compile-time shape check for RESHAPE assignments burnus at gcc dot gnu.org
2013-04-05 20:02 ` [Bug fortran/56849] " dominiq at lps dot ens.fr
2013-04-05 20:18 ` burnus at gcc dot gnu.org
2013-04-05 20:25 ` [Bug fortran/56849] Missing compile-time shape check for RESHAPE assignments with an ORDER= attribute dominiq at lps dot ens.fr
2013-04-05 20:38 ` burnus at gcc dot gnu.org
2013-04-08 20:13 ` burnus at gcc dot gnu.org
2013-04-08 20:14 ` burnus 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).