public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/38915]  New: wrong results for structure assignment of character components when left and right sides overlap
@ 2009-01-19 17:52 dick dot hendrickson at gmail dot com
  2009-01-19 18:49 ` [Bug fortran/38915] " burnus at gcc dot gnu dot org
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: dick dot hendrickson at gmail dot com @ 2009-01-19 17:52 UTC (permalink / raw)
  To: gcc-bugs

The following program gives the wrong results for the character assignments to
a structure component.  The problem appears to occur when there is an overlap
between the left and right hand sides of the assignment.  It is "as if" the
character length of the right hand side is treated as 1, rather than 9, and
then the left is blank padded to 9.  While experimenting with this, I tried
some simple things like L(1:2)%c = R(2:3)%c and they all worked.

Dick Hendrickson

       program cg0033_41

! fails on Windows XP
! gcc version 4.4.0 20081219 (experimental) [trunk revision 142842] (GCC)

       type t
         sequence
         integer i
         character(len=9) c
       end type t

       type (t)  L(3),R(3), LL(4), RR(4)
       EQUIVALENCE (L,LL)

       integer nfv1(3), nfv2(3)

       R(1)%c = '123456789'
       R(2)%c = 'abcdefghi'
       R(3)%c = '!@#$%^&*('

       L%c = R%c
       print *, 'simple assignment'
       print *,  R%c
       print *,  L%c

       LL(1:3)%c = R%c
       LL(4)%c = 'QWERTYUIO'
       RR%c = LL%c

       L%c = LL(2:4)%c

       print *
       print *, 'overlapping assignment'
       print *,  RR(2:4)%c
       print *,  L%c

       nfv1 = (/1,2,3/)
       nfv2 = nfv1
       L%c = R%c
       L(nfv1)%c = L(nfv2)%c
       print *
       print *, ' vvs assignment'
       print *,  R%c
       print *,  L%c

       end


C:\gfortran>gfortran try_cg0033_41.f

C:\gfortran>a
 simple assignment
 123456789abcdefghi!@#$%^&*(
 123456789abcdefghi!@#$%^&*(

 overlapping assignment
 abcdefghi!@#$%^&*(QWERTYUIO
 a        !        Q

  vvs assignment
 123456789abcdefghi!@#$%^&*(
 1        a        !


-- 
           Summary: wrong results for structure assignment of character
                    components when left and right sides overlap
           Product: gcc
           Version: 4.4.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: dick dot hendrickson at gmail dot com


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


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

* [Bug fortran/38915] wrong results for structure assignment of character components when left and right sides overlap
  2009-01-19 17:52 [Bug fortran/38915] New: wrong results for structure assignment of character components when left and right sides overlap dick dot hendrickson at gmail dot com
@ 2009-01-19 18:49 ` burnus at gcc dot gnu dot org
  2009-01-22 15:00 ` pault at gcc dot gnu dot org
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: burnus at gcc dot gnu dot org @ 2009-01-19 18:49 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from burnus at gcc dot gnu dot org  2009-01-19 18:49 -------
Confirm. ICE with 4.1.x and 4.2.x and wrong code with 4.3.x and 4.4.

Thanks for the report.


-- 

burnus at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
OtherBugsDependingO|                            |32834
              nThis|                            |
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|0                           |1
           Keywords|                            |wrong-code
   Last reconfirmed|0000-00-00 00:00:00         |2009-01-19 18:49:04
               date|                            |


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


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

* [Bug fortran/38915] wrong results for structure assignment of character components when left and right sides overlap
  2009-01-19 17:52 [Bug fortran/38915] New: wrong results for structure assignment of character components when left and right sides overlap dick dot hendrickson at gmail dot com
  2009-01-19 18:49 ` [Bug fortran/38915] " burnus at gcc dot gnu dot org
@ 2009-01-22 15:00 ` pault at gcc dot gnu dot org
  2009-01-28  6:22 ` [Bug fortran/38915] [Fix pending] " pault at gcc dot gnu dot org
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: pault at gcc dot gnu dot org @ 2009-01-22 15:00 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from pault at gcc dot gnu dot org  2009-01-22 15:00 -------
(In reply to comment #1)
> Confirm. ICE with 4.1.x and 4.2.x and wrong code with 4.3.x and 4.4.
> 
> Thanks for the report.
> 
The character length is being incorrectly set to 1 for the failing assignments;
ie. the last argument of the memmove is 1.

I'm on to it.

Paul


-- 

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|2009-01-19 18:49:04         |2009-01-22 15:00:32
               date|                            |


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


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

* [Bug fortran/38915] [Fix pending] wrong results for structure assignment of character components when left and right sides overlap
  2009-01-19 17:52 [Bug fortran/38915] New: wrong results for structure assignment of character components when left and right sides overlap dick dot hendrickson at gmail dot com
  2009-01-19 18:49 ` [Bug fortran/38915] " burnus at gcc dot gnu dot org
  2009-01-22 15:00 ` pault at gcc dot gnu dot org
@ 2009-01-28  6:22 ` pault at gcc dot gnu dot org
  2009-03-21 16:57 ` [Bug fortran/38915] " dominiq at lps dot ens dot fr
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: pault at gcc dot gnu dot org @ 2009-01-28  6:22 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from pault at gcc dot gnu dot org  2009-01-28 06:21 -------
See http://gcc.gnu.org/ml/fortran/2009-01/msg00331.html


-- 

pault at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|wrong results for structure |[Fix pending] wrong results
                   |assignment of character     |for structure assignment of
                   |components when left and    |character components when
                   |right sides overlap         |left and right sides overlap


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


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

* [Bug fortran/38915] wrong results for structure assignment of character components when left and right sides overlap
  2009-01-19 17:52 [Bug fortran/38915] New: wrong results for structure assignment of character components when left and right sides overlap dick dot hendrickson at gmail dot com
                   ` (2 preceding siblings ...)
  2009-01-28  6:22 ` [Bug fortran/38915] [Fix pending] " pault at gcc dot gnu dot org
@ 2009-03-21 16:57 ` dominiq at lps dot ens dot fr
  2009-03-31 20:04 ` pault at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: dominiq at lps dot ens dot fr @ 2009-03-21 16:57 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from dominiq at lps dot ens dot fr  2009-03-21 16:56 -------
Copy of http://gcc.gnu.org/ml/fortran/2009-01/msg00333.html:

> Bootstrapped and regtested on FC9/x86_64 - OK for 4.5?

Works as advertised on i686-apple-darwin9 (32 and 64 bit modes) without
regression. Since the patch fixes a wrong code, should not it be commited
in 4.4 (still 2 P1)?

Thanks for the patch.

Dominique

AFAICT this patch has not been reviewed.


-- 


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


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

* [Bug fortran/38915] wrong results for structure assignment of character components when left and right sides overlap
  2009-01-19 17:52 [Bug fortran/38915] New: wrong results for structure assignment of character components when left and right sides overlap dick dot hendrickson at gmail dot com
                   ` (3 preceding siblings ...)
  2009-03-21 16:57 ` [Bug fortran/38915] " dominiq at lps dot ens dot fr
@ 2009-03-31 20:04 ` pault at gcc dot gnu dot org
  2009-04-04  9:15 ` dominiq at lps dot ens dot fr
  2009-04-06 10:53 ` pault at gcc dot gnu dot org
  6 siblings, 0 replies; 8+ messages in thread
From: pault at gcc dot gnu dot org @ 2009-03-31 20:04 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #5 from pault at gcc dot gnu dot org  2009-03-31 20:03 -------
Subject: Bug 38915

Author: pault
Date: Tue Mar 31 20:03:23 2009
New Revision: 145370

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=145370
Log:
2009-03-31  Paul Thomas  <pault@gcc.gnu.org>

        PR fortran/38915
        * trans-expr.c (gfc_trans_assignment_1): Ensure temporaries
        have a string_length.

2009-03-31  Paul Thomas  <pault@gcc.gnu.org>

        PR fortran/38915
        * gfortran.dg/char_length_15.f90: New test.

Added:
    trunk/gcc/testsuite/gfortran.dg/char_length_15.f90
Modified:
    trunk/gcc/fortran/ChangeLog
    trunk/gcc/fortran/trans-expr.c
    trunk/gcc/testsuite/ChangeLog


-- 


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


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

* [Bug fortran/38915] wrong results for structure assignment of character components when left and right sides overlap
  2009-01-19 17:52 [Bug fortran/38915] New: wrong results for structure assignment of character components when left and right sides overlap dick dot hendrickson at gmail dot com
                   ` (4 preceding siblings ...)
  2009-03-31 20:04 ` pault at gcc dot gnu dot org
@ 2009-04-04  9:15 ` dominiq at lps dot ens dot fr
  2009-04-06 10:53 ` pault at gcc dot gnu dot org
  6 siblings, 0 replies; 8+ messages in thread
From: dominiq at lps dot ens dot fr @ 2009-04-04  9:15 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #6 from dominiq at lps dot ens dot fr  2009-04-04 09:14 -------
Could the patch be back-ported to 4.4 (4.3?)? TIA.


-- 


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


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

* [Bug fortran/38915] wrong results for structure assignment of character components when left and right sides overlap
  2009-01-19 17:52 [Bug fortran/38915] New: wrong results for structure assignment of character components when left and right sides overlap dick dot hendrickson at gmail dot com
                   ` (5 preceding siblings ...)
  2009-04-04  9:15 ` dominiq at lps dot ens dot fr
@ 2009-04-06 10:53 ` pault at gcc dot gnu dot org
  6 siblings, 0 replies; 8+ messages in thread
From: pault at gcc dot gnu dot org @ 2009-04-06 10:53 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #7 from pault at gcc dot gnu dot org  2009-04-06 10:53 -------
Fixed on trunk.  I am prepared to backport but the mood appears to be against
it.

Thanks for the report.

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=38915


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

end of thread, other threads:[~2009-04-06 10:53 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-01-19 17:52 [Bug fortran/38915] New: wrong results for structure assignment of character components when left and right sides overlap dick dot hendrickson at gmail dot com
2009-01-19 18:49 ` [Bug fortran/38915] " burnus at gcc dot gnu dot org
2009-01-22 15:00 ` pault at gcc dot gnu dot org
2009-01-28  6:22 ` [Bug fortran/38915] [Fix pending] " pault at gcc dot gnu dot org
2009-03-21 16:57 ` [Bug fortran/38915] " dominiq at lps dot ens dot fr
2009-03-31 20:04 ` pault at gcc dot gnu dot org
2009-04-04  9:15 ` dominiq at lps dot ens dot fr
2009-04-06 10:53 ` 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).