public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/47348] New: substring with len_trim in array constructor
@ 2011-01-18 18:45 tkoenig at gcc dot gnu.org
  2011-01-18 19:15 ` [Bug fortran/47348] " kargl at gcc dot gnu.org
                   ` (10 more replies)
  0 siblings, 11 replies; 12+ messages in thread
From: tkoenig at gcc dot gnu.org @ 2011-01-18 18:45 UTC (permalink / raw)
  To: gcc-bugs

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

           Summary: substring with len_trim in array constructor
           Product: gcc
           Version: 4.6.0
            Status: UNCONFIRMED
          Keywords: wrong-code
          Severity: normal
          Priority: P3
         Component: fortran
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: tkoenig@gcc.gnu.org
            Blocks: 19276


This one is strange; it is with recent trunk.

ig25@linux-fd1f:~/Krempel/Char-4> cat foo.f90
program main
  implicit none
  character(len=3) :: c(3)

  c = 'x'

  print '(3(A,"|"))', (/ (/ trim(c(1)), 'a' /)//'c', 'cd' /)
  print '(3(A,"|"))', (/ (/ c(1)(1:len_trim(c(1))), 'a' /)//'c', 'cd' /)
  print '(3(A,"|"))', (/ (/ c(1)(1:1), 'a' /)//'c', 'cd' /)
end program main
ig25@linux-fd1f:~/Krempel/Char-4> gfortran foo.f90
ig25@linux-fd1f:~/Krempel/Char-4> ./a.out
xc|ac|cd|
x |a |cd|
xc|ac|cd|

The second line should be identical to the first and third one.

Modified from nested_array_constructor_2.f90, BTW.

Goes back at least to 4.4.1, so probably not a regression.


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

* [Bug fortran/47348] substring with len_trim in array constructor
  2011-01-18 18:45 [Bug fortran/47348] New: substring with len_trim in array constructor tkoenig at gcc dot gnu.org
@ 2011-01-18 19:15 ` kargl at gcc dot gnu.org
  2011-01-18 20:43 ` tkoenig at gcc dot gnu.org
                   ` (9 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: kargl at gcc dot gnu.org @ 2011-01-18 19:15 UTC (permalink / raw)
  To: gcc-bugs

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

kargl at gcc dot gnu.org changed:

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

--- Comment #1 from kargl at gcc dot gnu.org 2011-01-18 18:42:45 UTC ---
gfortran 4.2.5 tries to grab 4 GB of memory and eventually
I killed the job.  With 4.3.something, I get

troutmask:sgk[211] gfc43 -o z df.f90 
df.f90: In function 'main':
df.f90:5: internal compiler error: Segmentation fault: 11
Please submit a full bug report,
with preprocessed source if appropriate.

Definitely, an interesting bug.


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

* [Bug fortran/47348] substring with len_trim in array constructor
  2011-01-18 18:45 [Bug fortran/47348] New: substring with len_trim in array constructor tkoenig at gcc dot gnu.org
  2011-01-18 19:15 ` [Bug fortran/47348] " kargl at gcc dot gnu.org
@ 2011-01-18 20:43 ` tkoenig at gcc dot gnu.org
  2011-01-19 19:45 ` [Bug fortran/47348] wrong string length with " tkoenig at gcc dot gnu.org
                   ` (8 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: tkoenig at gcc dot gnu.org @ 2011-01-18 20:43 UTC (permalink / raw)
  To: gcc-bugs

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

Thomas Koenig <tkoenig at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Blocks|                            |47065

--- Comment #2 from Thomas Koenig <tkoenig at gcc dot gnu.org> 2011-01-18 19:39:32 UTC ---
Of course, I can't replace trim(c(1)) with c(1)(1:len_trim(c(1)) until
this is resolved (which is why I found the bug in the first place),
so mark this as blocking PR 47065.


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

* [Bug fortran/47348] wrong string length with array constructor
  2011-01-18 18:45 [Bug fortran/47348] New: substring with len_trim in array constructor tkoenig at gcc dot gnu.org
  2011-01-18 19:15 ` [Bug fortran/47348] " kargl at gcc dot gnu.org
  2011-01-18 20:43 ` tkoenig at gcc dot gnu.org
@ 2011-01-19 19:45 ` tkoenig at gcc dot gnu.org
  2011-01-20  9:19 ` tkoenig at gcc dot gnu.org
                   ` (7 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: tkoenig at gcc dot gnu.org @ 2011-01-19 19:45 UTC (permalink / raw)
  To: gcc-bugs

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

Thomas Koenig <tkoenig at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|substring with len_trim in  |wrong string length with
                   |array constructor           |array constructor

--- Comment #3 from Thomas Koenig <tkoenig at gcc dot gnu.org> 2011-01-19 19:14:04 UTC ---
Reduced test case:

program main
  implicit none
  character(len=*), parameter :: fmt='(2(A,"|"))'
  integer :: i
  character(len=4) :: q

  q = 'yy'
  i = 2

  print fmt, (/ trim(q), 'ae' /)//'c'
  print fmt, (/ q(1:i), 'ae' /)//'c'

end program main

This prints

yyc|aec|
yy  c|ae  c|

so the string length of the array constructor is wrong.


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

* [Bug fortran/47348] wrong string length with array constructor
  2011-01-18 18:45 [Bug fortran/47348] New: substring with len_trim in array constructor tkoenig at gcc dot gnu.org
                   ` (2 preceding siblings ...)
  2011-01-19 19:45 ` [Bug fortran/47348] wrong string length with " tkoenig at gcc dot gnu.org
@ 2011-01-20  9:19 ` tkoenig at gcc dot gnu.org
  2011-01-22 17:48 ` paul.richard.thomas at gmail dot com
                   ` (6 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: tkoenig at gcc dot gnu.org @ 2011-01-20  9:19 UTC (permalink / raw)
  To: gcc-bugs

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

Thomas Koenig <tkoenig at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |pault at gcc dot gnu.org
             Blocks|                            |32834

--- Comment #4 from Thomas Koenig <tkoenig at gcc dot gnu.org> 2011-01-20 07:20:17 UTC ---
More reduced test case:

program main
  implicit none
  character(len=*), parameter :: fmt='(A,A)'
  integer :: i
  character(len=4) :: q

  q = 'abcd'
  i = 2
  print fmt, (/q(1:i) /),"|"

end program main

produces

ab  |

May be related to PR 44735, which is also an issue with
substrings with non-constant length.

Paul, this is a case of something (trans-*?) picking up the
wrong string length and ignoring the substring.  Do you have
any idea where to start looking?


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

* [Bug fortran/47348] wrong string length with array constructor
  2011-01-18 18:45 [Bug fortran/47348] New: substring with len_trim in array constructor tkoenig at gcc dot gnu.org
                   ` (3 preceding siblings ...)
  2011-01-20  9:19 ` tkoenig at gcc dot gnu.org
@ 2011-01-22 17:48 ` paul.richard.thomas at gmail dot com
  2011-02-19 15:11 ` pault at gcc dot gnu.org
                   ` (5 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: paul.richard.thomas at gmail dot com @ 2011-01-22 17:48 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 from paul.richard.thomas at gmail dot com <paul.richard.thomas at gmail dot com> 2011-01-22 16:50:00 UTC ---
Dear Thomas,

> Paul, this is a case of something (trans-*?) picking up the
> wrong string length and ignoring the substring.  Do you have
> any idea where to start looking?
>

Almost certainly.  I am very busy right now with reallocation in
scalar assignments.  I'll flag this one up.

cheers

Paul


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

* [Bug fortran/47348] wrong string length with array constructor
  2011-01-18 18:45 [Bug fortran/47348] New: substring with len_trim in array constructor tkoenig at gcc dot gnu.org
                   ` (4 preceding siblings ...)
  2011-01-22 17:48 ` paul.richard.thomas at gmail dot com
@ 2011-02-19 15:11 ` pault at gcc dot gnu.org
  2011-02-21 10:38 ` dominiq at lps dot ens.fr
                   ` (4 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: pault at gcc dot gnu.org @ 2011-02-19 15:11 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #6 from Paul Thomas <pault at gcc dot gnu.org> 2011-02-19 15:03:30 UTC ---
Author: pault
Date: Sat Feb 19 15:03:27 2011
New Revision: 170317

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=170317
Log:
2011-02-19  Paul Thomas  <pault@gcc.gnu.org>

    PR fortran/47348
    * trans-array.c (get_array_ctor_all_strlen): Move up in file.
    (get_array_ctor_var_strlen): Add block dummy and add call to
    get_array_ctor_all_strlen instead of giving up on substrings.
    Call gcc_unreachable for default case.
    (get_array_ctor_strlen): Add extra argument to in call to
    get_array_ctor_var_strlen.

2011-02-19  Paul Thomas  <pault@gcc.gnu.org>

    PR fortran/47348
    * gfortran.dg/array_constructor_36.f90 : New test.
    * gfortran.dg/bounds_check_10.f90 : Change dg-output message to
    allow for comparison between different elements of the array
    constructor at different levels of optimization.


Added:
    trunk/gcc/testsuite/gfortran.dg/array_constructor_36.f90
Modified:
    trunk/gcc/fortran/ChangeLog
    trunk/gcc/fortran/trans-array.c
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/testsuite/gfortran.dg/bounds_check_10.f90


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

* [Bug fortran/47348] wrong string length with array constructor
  2011-01-18 18:45 [Bug fortran/47348] New: substring with len_trim in array constructor tkoenig at gcc dot gnu.org
                   ` (5 preceding siblings ...)
  2011-02-19 15:11 ` pault at gcc dot gnu.org
@ 2011-02-21 10:38 ` dominiq at lps dot ens.fr
  2011-02-21 12:10 ` pault at gcc dot gnu.org
                   ` (3 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: dominiq at lps dot ens.fr @ 2011-02-21 10:38 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2011.02.21 10:33:10
     Ever Confirmed|0                           |1

--- Comment #7 from Dominique d'Humieres <dominiq at lps dot ens.fr> 2011-02-21 10:33:10 UTC ---
Any plan to backport the fix in revision 170317?


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

* [Bug fortran/47348] wrong string length with array constructor
  2011-01-18 18:45 [Bug fortran/47348] New: substring with len_trim in array constructor tkoenig at gcc dot gnu.org
                   ` (6 preceding siblings ...)
  2011-02-21 10:38 ` dominiq at lps dot ens.fr
@ 2011-02-21 12:10 ` pault at gcc dot gnu.org
  2011-02-21 22:49 ` tkoenig at netcologne dot de
                   ` (2 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: pault at gcc dot gnu.org @ 2011-02-21 12:10 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #8 from Paul Thomas <pault at gcc dot gnu.org> 2011-02-21 12:06:42 UTC ---
(In reply to comment #7)
> Any plan to backport the fix in revision 170317?

I had not planned so to do but would respond positively to popular pressure how
far back would you want to go?

Paul


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

* [Bug fortran/47348] wrong string length with array constructor
  2011-01-18 18:45 [Bug fortran/47348] New: substring with len_trim in array constructor tkoenig at gcc dot gnu.org
                   ` (7 preceding siblings ...)
  2011-02-21 12:10 ` pault at gcc dot gnu.org
@ 2011-02-21 22:49 ` tkoenig at netcologne dot de
  2011-03-13 17:38 ` pault at gcc dot gnu.org
  2011-03-13 17:41 ` pault at gcc dot gnu.org
  10 siblings, 0 replies; 12+ messages in thread
From: tkoenig at netcologne dot de @ 2011-02-21 22:49 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #9 from tkoenig at netcologne dot de <tkoenig at netcologne dot de> 2011-02-21 22:40:52 UTC ---
Hi Paul,

> (In reply to comment #7)
>> Any plan to backport the fix in revision 170317?
> 
> I had not planned so to do but would respond positively to popular pressure how
> far back would you want to go?

I think 4.5 would be great.  Anything further back is probably unneeded
(the bug has remained undetected for a few years now...)

Thomas


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

* [Bug fortran/47348] wrong string length with array constructor
  2011-01-18 18:45 [Bug fortran/47348] New: substring with len_trim in array constructor tkoenig at gcc dot gnu.org
                   ` (8 preceding siblings ...)
  2011-02-21 22:49 ` tkoenig at netcologne dot de
@ 2011-03-13 17:38 ` pault at gcc dot gnu.org
  2011-03-13 17:41 ` pault at gcc dot gnu.org
  10 siblings, 0 replies; 12+ messages in thread
From: pault at gcc dot gnu.org @ 2011-03-13 17:38 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #10 from Paul Thomas <pault at gcc dot gnu.org> 2011-03-13 17:37:47 UTC ---
Author: pault
Date: Sun Mar 13 17:37:43 2011
New Revision: 170923

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

    PR fortran/47348
    * trans-array.c (get_array_ctor_all_strlen): Move up in file.
    (get_array_ctor_var_strlen): Add block dummy and add call to
    get_array_ctor_all_strlen instead of giving up on substrings.
    Call gcc_unreachable for default case.
    (get_array_ctor_strlen): Add extra argument to in call to
    get_array_ctor_var_strlen.

2011-03-13  Paul Thomas  <pault@gcc.gnu.org>

    PR fortran/47348
    * gfortran.dg/array_constructor_36.f90 : New test.
    * gfortran.dg/bounds_check_10.f90 : Change dg-output message to
    allow for comparison between different elements of the array
    constructor at different levels of optimization.


Added:
    branches/gcc-4_5-branch/gcc/testsuite/gfortran.dg/array_constructor_36.f90
Modified:
    branches/gcc-4_5-branch/gcc/fortran/ChangeLog
    branches/gcc-4_5-branch/gcc/fortran/trans-array.c
    branches/gcc-4_5-branch/gcc/testsuite/ChangeLog


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

* [Bug fortran/47348] wrong string length with array constructor
  2011-01-18 18:45 [Bug fortran/47348] New: substring with len_trim in array constructor tkoenig at gcc dot gnu.org
                   ` (9 preceding siblings ...)
  2011-03-13 17:38 ` pault at gcc dot gnu.org
@ 2011-03-13 17:41 ` pault at gcc dot gnu.org
  10 siblings, 0 replies; 12+ messages in thread
From: pault at gcc dot gnu.org @ 2011-03-13 17:41 UTC (permalink / raw)
  To: gcc-bugs

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

Paul Thomas <pault at gcc dot gnu.org> changed:

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

--- Comment #11 from Paul Thomas <pault at gcc dot gnu.org> 2011-03-13 17:40:13 UTC ---
(In reply to comment #10)
Fixed on 4.5 and trunk.

Closing

Thanks for the report.

Paul


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

end of thread, other threads:[~2011-03-13 17:41 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-01-18 18:45 [Bug fortran/47348] New: substring with len_trim in array constructor tkoenig at gcc dot gnu.org
2011-01-18 19:15 ` [Bug fortran/47348] " kargl at gcc dot gnu.org
2011-01-18 20:43 ` tkoenig at gcc dot gnu.org
2011-01-19 19:45 ` [Bug fortran/47348] wrong string length with " tkoenig at gcc dot gnu.org
2011-01-20  9:19 ` tkoenig at gcc dot gnu.org
2011-01-22 17:48 ` paul.richard.thomas at gmail dot com
2011-02-19 15:11 ` pault at gcc dot gnu.org
2011-02-21 10:38 ` dominiq at lps dot ens.fr
2011-02-21 12:10 ` pault at gcc dot gnu.org
2011-02-21 22:49 ` tkoenig at netcologne dot de
2011-03-13 17:38 ` pault at gcc dot gnu.org
2011-03-13 17:41 ` pault 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).