public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/103115] New: reallocation of character array fails when appending a constant size 4 array
@ 2021-11-07 11:01 ygalklein at gmail dot com
  2021-11-07 11:05 ` [Bug fortran/103115] " ygalklein at gmail dot com
                   ` (9 more replies)
  0 siblings, 10 replies; 11+ messages in thread
From: ygalklein at gmail dot com @ 2021-11-07 11:01 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103115

            Bug ID: 103115
           Summary: reallocation of character array fails when appending a
                    constant size 4 array
           Product: gcc
           Version: 11.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: ygalklein at gmail dot com
  Target Milestone: ---

The following example program:
```fortran
program reallocationCharacterArray
    implicit none
    character(:), dimension(:), allocatable :: titles
    titles = ["1"]
    titles = [titles,&
            "2",&
            "3",&
            "4",&
            "5"&
            ]
    block
        integer :: iTitle
        do iTitle = 1, size(titles)
            write(*, "('titles(',i2,') = ',a)") iTitle, trim(titles(iTitle))
        end do
    end block
end program reallocationCharacterArray
```

when compiled using gfortran 11.1 or 10.3 results with the following output:
`
size(titles) = 5
titles( 1) = 1
titles( 2) = 
titles( 3) = 
titles( 4) = 
titles( 5) = 
`

which is clearly wrong.
One can see that the reallocation succeded in increasing the size of titles
from 1 to 5 - but the assignment to all the places from 2 to 5 are erronous.

one should note that using intel compiler 2021.4 - results with the following
output:
`
size(titles) = 5
titles( 1) = 1
titles( 2) = 2
titles( 3) = 3
titles( 4) = 4
titles( 5) = 5
`

which is the right output.

One should also note that commenting one line from the constant array being
appended - i.e appending an array of size 3 (instead of size 4) results with
the right output when using gfortran, i.e

the following program (note the ! sign commenting one line):
```fortran
program reallocationCharacterArray
    implicit none
    character(:), dimension(:), allocatable :: titles
    titles = ["1"]
    titles = [titles,&
            ! "2",&
            "3",&
            "4",&
            "5"&
            ]
    write(*, "('size(titles) = ',i1)") size(titles)
    block
        integer :: iTitle    
        do iTitle = 1, size(titles)
            write(*, "('titles(',i2,') = ',a)") iTitle, trim(titles(iTitle))
        end do
    end block
end program reallocationCharacterArray
```

results with the following right output:
`
size(titles) = 4
titles( 1) = 1
titles( 2) = 3
titles( 3) = 4
titles( 4) = 5
`

both in gfortran and ifort.

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

* [Bug fortran/103115] reallocation of character array fails when appending a constant size 4 array
  2021-11-07 11:01 [Bug fortran/103115] New: reallocation of character array fails when appending a constant size 4 array ygalklein at gmail dot com
@ 2021-11-07 11:05 ` ygalklein at gmail dot com
  2021-11-15 19:32 ` [Bug fortran/103115] [12 Regression] " tkoenig at gcc dot gnu.org
                   ` (8 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: ygalklein at gmail dot com @ 2021-11-07 11:05 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103115

--- Comment #1 from ygal klein <ygalklein at gmail dot com> ---
I see that in the first program I gave as an example I forgot to insert the
line

write(*, "('size(titles) = ',i1)") size(titles)

bf the block

anyway - it is there (one can see the output).

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

* [Bug fortran/103115] [12 Regression] reallocation of character array fails when appending a constant size 4 array
  2021-11-07 11:01 [Bug fortran/103115] New: reallocation of character array fails when appending a constant size 4 array ygalklein at gmail dot com
  2021-11-07 11:05 ` [Bug fortran/103115] " ygalklein at gmail dot com
@ 2021-11-15 19:32 ` tkoenig at gcc dot gnu.org
  2021-11-16 12:29 ` juergen.reuter at desy dot de
                   ` (7 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: tkoenig at gcc dot gnu.org @ 2021-11-15 19:32 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103115

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |ice-on-valid-code,
                   |                            |wrong-code
             Status|UNCONFIRMED                 |NEW
            Summary|reallocation of character   |[12 Regression]
                   |array fails when appending  |reallocation of character
                   |a constant size 4 array     |array fails when appending
                   |                            |a constant size 4 array
     Ever confirmed|0                           |1
   Target Milestone|---                         |12.0
   Last reconfirmed|                            |2021-11-15
                 CC|                            |tkoenig at gcc dot gnu.org

--- Comment #2 from Thomas Koenig <tkoenig at gcc dot gnu.org> ---
I can confirm the bug with gcc 9 (didn't check any other
version).

Current trunk gives me

.f90:10:13:

   10 |             ]
      |             1
interner Compiler-Fehler: tree check: expected integer_cst, have save_expr in
gfc_trans_array_constructor_value, at fortran/trans-array.c:2187
0x1002ebcf tree_check_failed(tree_node const*, char const*, int, char const*,
...)
        ../../trunk/gcc/tree.c:8689
0x101d89bf tree_int_cst_elt_check(tree_node*, int, char const*, int, char
const*)
        ../../trunk/gcc/tree.h:3633
0x101d89bf tree_int_cst_elt_check(tree_node*, int, char const*, int, char
const*)
        ../../trunk/gcc/tree.h:3629
0x101d89bf gfc_trans_array_constructor_value
        ../../trunk/gcc/fortran/trans-array.c:2187
0x101d9563 trans_array_constructor
        ../../trunk/gcc/fortran/trans-array.c:2900
0x101d9563 gfc_add_loop_ss_code
        ../../trunk/gcc/fortran/trans-array.c:3180
0x101d9f6f gfc_conv_loop_setup(gfc_loopinfo*, locus*)
        ../../trunk/gcc/fortran/trans-array.c:5430
0x102350db gfc_trans_assignment_1
        ../../trunk/gcc/fortran/trans-expr.c:11642
0x101ba337 trans_code
        ../../trunk/gcc/fortran/trans.c:1916

Marking as regression for the ICE at least.

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

* [Bug fortran/103115] [12 Regression] reallocation of character array fails when appending a constant size 4 array
  2021-11-07 11:01 [Bug fortran/103115] New: reallocation of character array fails when appending a constant size 4 array ygalklein at gmail dot com
  2021-11-07 11:05 ` [Bug fortran/103115] " ygalklein at gmail dot com
  2021-11-15 19:32 ` [Bug fortran/103115] [12 Regression] " tkoenig at gcc dot gnu.org
@ 2021-11-16 12:29 ` juergen.reuter at desy dot de
  2021-11-16 13:07 ` tkoenig at gcc dot gnu.org
                   ` (6 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: juergen.reuter at desy dot de @ 2021-11-16 12:29 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103115

Jürgen Reuter <juergen.reuter at desy dot de> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |juergen.reuter at desy dot de

--- Comment #3 from Jürgen Reuter <juergen.reuter at desy dot de> ---
(In reply to Thomas Koenig from comment #2)
> I can confirm the bug with gcc 9 (didn't check any other
> version).
> 
> Current trunk gives me
> 
> .f90:10:13:
> 
>    10 |             ]
>       |             1
> interner Compiler-Fehler: tree check: expected integer_cst, have save_expr
> in gfc_trans_array_constructor_value, at fortran/trans-array.c:2187
> 0x1002ebcf tree_check_failed(tree_node const*, char const*, int, char
> const*, ...)
>         ../../trunk/gcc/tree.c:8689
> 0x101d89bf tree_int_cst_elt_check(tree_node*, int, char const*, int, char
> const*)
>         ../../trunk/gcc/tree.h:3633
> 0x101d89bf tree_int_cst_elt_check(tree_node*, int, char const*, int, char
> const*)
>         ../../trunk/gcc/tree.h:3629
> 0x101d89bf gfc_trans_array_constructor_value
>         ../../trunk/gcc/fortran/trans-array.c:2187
> 0x101d9563 trans_array_constructor
>         ../../trunk/gcc/fortran/trans-array.c:2900
> 0x101d9563 gfc_add_loop_ss_code
>         ../../trunk/gcc/fortran/trans-array.c:3180
> 0x101d9f6f gfc_conv_loop_setup(gfc_loopinfo*, locus*)
>         ../../trunk/gcc/fortran/trans-array.c:5430
> 0x102350db gfc_trans_assignment_1
>         ../../trunk/gcc/fortran/trans-expr.c:11642
> 0x101ba337 trans_code
>         ../../trunk/gcc/fortran/trans.c:1916
> 
> Marking as regression for the ICE at least.

Thomas, are you sure? I cannot see an ICE, neither with the master from
September 21 nor with the master from yesterday.

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

* [Bug fortran/103115] [12 Regression] reallocation of character array fails when appending a constant size 4 array
  2021-11-07 11:01 [Bug fortran/103115] New: reallocation of character array fails when appending a constant size 4 array ygalklein at gmail dot com
                   ` (2 preceding siblings ...)
  2021-11-16 12:29 ` juergen.reuter at desy dot de
@ 2021-11-16 13:07 ` tkoenig at gcc dot gnu.org
  2021-11-16 15:42 ` tkoenig at gcc dot gnu.org
                   ` (5 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: tkoenig at gcc dot gnu.org @ 2021-11-16 13:07 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103115

--- Comment #4 from Thomas Koenig <tkoenig at gcc dot gnu.org> ---
(In reply to Jürgen Reuter from comment #3)

> Thomas, are you sure? I cannot see an ICE, neither with the master from
> September 21 nor with the master from yesterday.

I see the ICE with

gcc version 12.0.0 20211028 (experimental) (GCC) 

I'll run a bootstrap and re-check.

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

* [Bug fortran/103115] [12 Regression] reallocation of character array fails when appending a constant size 4 array
  2021-11-07 11:01 [Bug fortran/103115] New: reallocation of character array fails when appending a constant size 4 array ygalklein at gmail dot com
                   ` (3 preceding siblings ...)
  2021-11-16 13:07 ` tkoenig at gcc dot gnu.org
@ 2021-11-16 15:42 ` tkoenig at gcc dot gnu.org
  2021-11-17  9:07 ` juergen.reuter at desy dot de
                   ` (4 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: tkoenig at gcc dot gnu.org @ 2021-11-16 15:42 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103115

--- Comment #5 from Thomas Koenig <tkoenig at gcc dot gnu.org> ---
I can confirm the ICE with current trunk both on x86_64 and
on POWER.

x86_64:

$ gfortran -v
Es werden eingebaute Spezifikationen verwendet.
COLLECT_GCC=gfortran
COLLECT_LTO_WRAPPER=/home/ig25/libexec/gcc/x86_64-pc-linux-gnu/12.0.0/lto-wrapper
Ziel: x86_64-pc-linux-gnu
Konfiguriert mit: ../trunk/configure --prefix=/home/ig25
--enable-languages=c,c++,fortran --enable-maintainer-mode
Thread-Modell: posix
Unterstützte LTO-Kompressionsalgorithmen: zlib
gcc-Version 12.0.0 20211116 (experimental) [master revision
e87559d202d:f4e6da6e8ac:36ec54aac7da134441c83248e14825381b8d6f17] (GCC) 
$ gfortran a.f90 
a.f90:10:13:

   10 |             ]
      |             1
interner Compiler-Fehler: tree check: expected integer_cst, have save_expr in
gfc_trans_array_constructor_value, at fortran/trans-array.c:2187
0x808a8a tree_check_failed(tree_node const*, char const*, int, char const*,
...)
        ../../trunk/gcc/tree.c:8701

POWER:

tkoenig@gcc135 ~]$ gfortran -v
Using built-in specs.
COLLECT_GCC=gfortran
COLLECT_LTO_WRAPPER=/home/tkoenig/libexec/gcc/powerpc64le-unknown-linux-gnu/12.0.0/lto-wrapper
Target: powerpc64le-unknown-linux-gnu
Configured with: ../trunk/configure --prefix=/home/tkoenig
--enable-languages=c,c++,fortran
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 12.0.0 20211116 (experimental) (GCC) 
[tkoenig@gcc135 ~]$ gfortran a.f90 
a.f90:10:13:

   10 |             ]
      |             1
internal compiler error: tree check: expected integer_cst, have save_expr in
gfc_trans_array_constructor_value, at fortran/trans-array.c:2187
0x1025d7ff tree_check_failed(tree_node const*, char const*, int, char const*,
...)
        ../../trunk/gcc/tree.c:8701
0x10408c23 tree_int_cst_elt_check(tree_node*, int, char const*, int, char
const*)
        ../../trunk/gcc/tree.h:3641

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

* [Bug fortran/103115] [12 Regression] reallocation of character array fails when appending a constant size 4 array
  2021-11-07 11:01 [Bug fortran/103115] New: reallocation of character array fails when appending a constant size 4 array ygalklein at gmail dot com
                   ` (4 preceding siblings ...)
  2021-11-16 15:42 ` tkoenig at gcc dot gnu.org
@ 2021-11-17  9:07 ` juergen.reuter at desy dot de
  2021-11-17 16:30 ` tkoenig at gcc dot gnu.org
                   ` (3 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: juergen.reuter at desy dot de @ 2021-11-17  9:07 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103115

--- Comment #6 from Jürgen Reuter <juergen.reuter at desy dot de> ---
(In reply to Thomas Koenig from comment #5)
> I can confirm the ICE with current trunk both on x86_64 and
> on POWER.
> 
> x86_64:
> 
> $ gfortran -v
> Es werden eingebaute Spezifikationen verwendet.
> COLLECT_GCC=gfortran
> COLLECT_LTO_WRAPPER=/home/ig25/libexec/gcc/x86_64-pc-linux-gnu/12.0.0/lto-
> wrapper
> Ziel: x86_64-pc-linux-gnu
> Konfiguriert mit: ../trunk/configure --prefix=/home/ig25
> --enable-languages=c,c++,fortran --enable-maintainer-mode
> Thread-Modell: posix
> Unterstützte LTO-Kompressionsalgorithmen: zlib
> gcc-Version 12.0.0 20211116 (experimental) [master revision
> e87559d202d:f4e6da6e8ac:36ec54aac7da134441c83248e14825381b8d6f17] (GCC) 
> $ gfortran a.f90 
> a.f90:10:13:
> 
>    10 |             ]
>       |             1
> interner Compiler-Fehler: tree check: expected integer_cst, have save_expr
> in gfc_trans_array_constructor_value, at fortran/trans-array.c:2187
> 0x808a8a tree_check_failed(tree_node const*, char const*, int, char const*,
> ...)
>         ../../trunk/gcc/tree.c:8701
> 
> POWER:
> 


Really interesting, I don't get an ICE with the following setup:
../configure --prefix=/usr/local/ --with-gmp=/usr/local/
--with-mpfr=/usr/local/ --with-mp=/usr/local/
--with-sysroot=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/
--enable-checking=release --enable-languages=c,c++,fortran,lto,objc,obj-c++
$ gfortran --version
GNU Fortran (GCC) 12.0.0 20211115 (experimental)
Maybe the enable-checking setup!?

I am compiling without any flags the code snippet in the very first post in
this PR.

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

* [Bug fortran/103115] [12 Regression] reallocation of character array fails when appending a constant size 4 array
  2021-11-07 11:01 [Bug fortran/103115] New: reallocation of character array fails when appending a constant size 4 array ygalklein at gmail dot com
                   ` (5 preceding siblings ...)
  2021-11-17  9:07 ` juergen.reuter at desy dot de
@ 2021-11-17 16:30 ` tkoenig at gcc dot gnu.org
  2022-01-17 13:00 ` rguenth at gcc dot gnu.org
                   ` (2 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: tkoenig at gcc dot gnu.org @ 2021-11-17 16:30 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103115

--- Comment #7 from Thomas Koenig <tkoenig at gcc dot gnu.org> ---
(In reply to Jürgen Reuter from comment #6)

> Really interesting, I don't get an ICE with the following setup:
> ../configure --prefix=/usr/local/ --with-gmp=/usr/local/
> --with-mpfr=/usr/local/ --with-mp=/usr/local/
> --with-sysroot=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.
> platform/Developer/SDKs/MacOSX.sdk/ --enable-checking=release
> --enable-languages=c,c++,fortran,lto,objc,obj-c++
> $ gfortran --version
> GNU Fortran (GCC) 12.0.0 20211115 (experimental)
> Maybe the enable-checking setup!?

Extremely likely.

--enable-checking=release turns off a very large number of checks
which are really only interesting for developers to find bugs,
and which make the compiler run rather slowly.

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

* [Bug fortran/103115] [12 Regression] reallocation of character array fails when appending a constant size 4 array
  2021-11-07 11:01 [Bug fortran/103115] New: reallocation of character array fails when appending a constant size 4 array ygalklein at gmail dot com
                   ` (6 preceding siblings ...)
  2021-11-17 16:30 ` tkoenig at gcc dot gnu.org
@ 2022-01-17 13:00 ` rguenth at gcc dot gnu.org
  2022-05-06  8:31 ` [Bug fortran/103115] [12/13 " jakub at gcc dot gnu.org
  2023-05-08 12:23 ` [Bug fortran/103115] [12/13/14 " rguenth at gcc dot gnu.org
  9 siblings, 0 replies; 11+ messages in thread
From: rguenth at gcc dot gnu.org @ 2022-01-17 13:00 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103115

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P3                          |P4

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

* [Bug fortran/103115] [12/13 Regression] reallocation of character array fails when appending a constant size 4 array
  2021-11-07 11:01 [Bug fortran/103115] New: reallocation of character array fails when appending a constant size 4 array ygalklein at gmail dot com
                   ` (7 preceding siblings ...)
  2022-01-17 13:00 ` rguenth at gcc dot gnu.org
@ 2022-05-06  8:31 ` jakub at gcc dot gnu.org
  2023-05-08 12:23 ` [Bug fortran/103115] [12/13/14 " rguenth at gcc dot gnu.org
  9 siblings, 0 replies; 11+ messages in thread
From: jakub at gcc dot gnu.org @ 2022-05-06  8:31 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103115

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|12.0                        |12.2

--- Comment #8 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
GCC 12.1 is being released, retargeting bugs to GCC 12.2.

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

* [Bug fortran/103115] [12/13/14 Regression] reallocation of character array fails when appending a constant size 4 array
  2021-11-07 11:01 [Bug fortran/103115] New: reallocation of character array fails when appending a constant size 4 array ygalklein at gmail dot com
                   ` (8 preceding siblings ...)
  2022-05-06  8:31 ` [Bug fortran/103115] [12/13 " jakub at gcc dot gnu.org
@ 2023-05-08 12:23 ` rguenth at gcc dot gnu.org
  9 siblings, 0 replies; 11+ messages in thread
From: rguenth at gcc dot gnu.org @ 2023-05-08 12:23 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103115

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|12.3                        |12.4

--- Comment #10 from Richard Biener <rguenth at gcc dot gnu.org> ---
GCC 12.3 is being released, retargeting bugs to GCC 12.4.

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

end of thread, other threads:[~2023-05-08 12:23 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-07 11:01 [Bug fortran/103115] New: reallocation of character array fails when appending a constant size 4 array ygalklein at gmail dot com
2021-11-07 11:05 ` [Bug fortran/103115] " ygalklein at gmail dot com
2021-11-15 19:32 ` [Bug fortran/103115] [12 Regression] " tkoenig at gcc dot gnu.org
2021-11-16 12:29 ` juergen.reuter at desy dot de
2021-11-16 13:07 ` tkoenig at gcc dot gnu.org
2021-11-16 15:42 ` tkoenig at gcc dot gnu.org
2021-11-17  9:07 ` juergen.reuter at desy dot de
2021-11-17 16:30 ` tkoenig at gcc dot gnu.org
2022-01-17 13:00 ` rguenth at gcc dot gnu.org
2022-05-06  8:31 ` [Bug fortran/103115] [12/13 " jakub at gcc dot gnu.org
2023-05-08 12:23 ` [Bug fortran/103115] [12/13/14 " rguenth 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).