public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/60795] New: Wrong length when allocating character array
@ 2014-04-09 15:00 kergonath at me dot com
  2014-04-09 17:08 ` [Bug fortran/60795] [4.7/4.8/4.9 Regression] " dominiq at lps dot ens.fr
                   ` (10 more replies)
  0 siblings, 11 replies; 12+ messages in thread
From: kergonath at me dot com @ 2014-04-09 15:00 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 60795
           Summary: Wrong length when allocating character array
           Product: gcc
           Version: 4.9.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: kergonath at me dot com

In the following program:

program stringtest
  character(:), dimension(:), allocatable :: s

  allocate(character(1) :: s(10))
  write(*,*) size(s)
  write(*,*) len(s)
end program

the elements of the array s end up with the wrong length, the output is:
          10
           0

Tested with latest version available with macports:
Using built-in specs.
COLLECT_GCC=gfortran
COLLECT_LTO_WRAPPER=/opt/local/libexec/gcc/x86_64-apple-darwin13/4.9.0/lto-wrapper
Target: x86_64-apple-darwin13
Configured with:
/opt/local/var/macports/build/_opt_mports_dports_lang_gcc49/gcc49/work/gcc-4.9-20140406/configure
--prefix=/opt/local --build=x86_64-apple-darwin13
--enable-languages=c,c++,objc,obj-c++,fortran,java
--libdir=/opt/local/lib/gcc49 --includedir=/opt/local/include/gcc49
--infodir=/opt/local/share/info --mandir=/opt/local/share/man
--datarootdir=/opt/local/share/gcc-4.9 --with-local-prefix=/opt/local
--with-system-zlib --disable-nls --program-suffix=-mp-4.9
--with-gxx-include-dir=/opt/local/include/gcc49/c++/ --with-gmp=/opt/local
--with-mpfr=/opt/local --with-mpc=/opt/local --with-cloog=/opt/local
--enable-cloog-backend=isl --disable-cloog-version-check
--enable-stage1-checking --disable-multilib --enable-lto
--enable-libstdcxx-time --with-as=/opt/local/bin/as --with-ld=/opt/local/bin/ld
--with-ar=/opt/local/bin/ar --with-bugurl=https://trac.macports.org/newticket
--with-pkgversion='MacPorts gcc49 4.9-20140406_0'
Thread model: posix
gcc version 4.9.0 20140406 (experimental) (MacPorts gcc49 4.9-20140406_0)


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

* [Bug fortran/60795] [4.7/4.8/4.9 Regression] Wrong length when allocating character array
  2014-04-09 15:00 [Bug fortran/60795] New: Wrong length when allocating character array kergonath at me dot com
@ 2014-04-09 17:08 ` dominiq at lps dot ens.fr
  2014-04-09 18:38 ` kargl at gcc dot gnu.org
                   ` (9 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: dominiq at lps dot ens.fr @ 2014-04-09 17:08 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
      Known to work|                            |4.6.0
           Keywords|                            |wrong-code
   Last reconfirmed|                            |2014-04-09
                 CC|                            |jb at gcc dot gnu.org
     Ever confirmed|0                           |1
            Summary|Wrong length when           |[4.7/4.8/4.9 Regression]
                   |allocating character array  |Wrong length when
                   |                            |allocating character array
      Known to fail|                            |4.7.4, 4.8.3, 4.9.0

--- Comment #1 from Dominique d'Humieres <dominiq at lps dot ens.fr> ---
Confirmed, up to revision r173749 I get

          10
           1

from r173750 to r174379 I get

          10
           2

and from r174433 up to r209236 I get

          10
           0

What is surprising is that r173750, r174030, and r174415 are related to
backtrace handling, so they probably only expose a latent problem(?).


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

* [Bug fortran/60795] [4.7/4.8/4.9 Regression] Wrong length when allocating character array
  2014-04-09 15:00 [Bug fortran/60795] New: Wrong length when allocating character array kergonath at me dot com
  2014-04-09 17:08 ` [Bug fortran/60795] [4.7/4.8/4.9 Regression] " dominiq at lps dot ens.fr
@ 2014-04-09 18:38 ` kargl at gcc dot gnu.org
  2014-04-10  0:25 ` quantheory at gmail dot com
                   ` (8 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: kargl at gcc dot gnu.org @ 2014-04-09 18:38 UTC (permalink / raw)
  To: gcc-bugs

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

kargl at gcc dot gnu.org changed:

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

--- Comment #2 from kargl at gcc dot gnu.org ---
(In reply to Dominique d'Humieres from comment #1)
>
> What is surprising is that r173750, r174030, and r174415 are related to
> backtrace handling, so they probably only expose a latent problem(?).
>

I think it is a lot worse than it appears.

call s1
call s2
call s3
end

subroutine s1
  character(:), dimension(:), allocatable :: s
  allocate(character(10) :: s(2))
  s(1) = 'r'
  s(2) = 's'
  print *, 's1: ', size(s), len(s)
end subroutine s1
!
! A variation on a theme?
!
subroutine s2
!  This causes an ICE in gfortran
!  character(:), dimension(:), allocatable :: s
!  allocate(s(2), source='abc')
!  s(1) = 'r'
!  s(2) = 's'
!  print *, 's2:', size(s), len(s)
end subroutine s2
!
! A variation on a theme?
!
subroutine s3
!  This causes an ICE in gfortran
!  character(:), dimension(:), allocatable :: s
!  allocate(s(2), source=['abc','def'])
!  allocate(s, source=['abc','def'])
!  s(1) = 'r'
!  s(2) = 's'
!  print *, 's3:', size(s), len(s)
end subroutine s3

subroutine y3
!  This causes gfortran to issue an error.  Incorrect!
!  character(:), dimension(:), allocatable :: s
!  allocate(s, source=['abc','def'])
!  s(1) = 'r'
!  s(2) = 's'
!  print *, 's3:', size(s), len(s)
end subroutine y3

subroutine t3
!  This causes gfortran to issue an error. Incorrect!
!  real, dimension(:), allocatable :: s
!  allocate(s, source=[1., 2.])
end subroutine t3

subroutine s4
!  This causes an ICE in gfortran
!  character(3), dimension(:), allocatable :: s
!  allocate(s(2), source=['abc','def'])
!  s(1) = 'r'
!  s(2) = 's'
!  print *, 's3:', size(s), len(s)
end subroutine s4


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

* [Bug fortran/60795] [4.7/4.8/4.9 Regression] Wrong length when allocating character array
  2014-04-09 15:00 [Bug fortran/60795] New: Wrong length when allocating character array kergonath at me dot com
  2014-04-09 17:08 ` [Bug fortran/60795] [4.7/4.8/4.9 Regression] " dominiq at lps dot ens.fr
  2014-04-09 18:38 ` kargl at gcc dot gnu.org
@ 2014-04-10  0:25 ` quantheory at gmail dot com
  2014-04-10  9:30 ` kergonath at me dot com
                   ` (7 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: quantheory at gmail dot com @ 2014-04-10  0:25 UTC (permalink / raw)
  To: gcc-bugs

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

Sean Santos <quantheory at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |quantheory at gmail dot com

--- Comment #3 from Sean Santos <quantheory at gmail dot com> ---
In comment 2, "y3", "t3", and the second allocation of "s3" are all cases of
PR44672; this is an unsupported feature of F2008.

The original case (comment 0, "s1") may be a duplicate of PR57456.

The case "s2" looks like a duplicate of PR58754, and "s3" and "s4" may be the
same issue. Or they may be related to PR50221.

So there are clearly some issues here, but I think that they are mostly old
issues, i.e. arrays of deferred-length strings have always been somewhat
broken.

I remember something about some intention to address this when implementing the
new array descriptor, though?


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

* [Bug fortran/60795] [4.7/4.8/4.9 Regression] Wrong length when allocating character array
  2014-04-09 15:00 [Bug fortran/60795] New: Wrong length when allocating character array kergonath at me dot com
                   ` (2 preceding siblings ...)
  2014-04-10  0:25 ` quantheory at gmail dot com
@ 2014-04-10  9:30 ` kergonath at me dot com
  2014-04-11  9:13 ` rguenth at gcc dot gnu.org
                   ` (6 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: kergonath at me dot com @ 2014-04-10  9:30 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from Kergonath <kergonath at me dot com> ---
The slightly modified version:
module m
contains
    subroutine allocate_array(s_array)
        character(:), dimension(:), allocatable, intent(out) :: s_array

        allocate(character(2) :: s_array(10))
        write(*,*) len(s_array), size(s_array)
    end subroutine
end module

program stringtest
    use m
    character(:), dimension(:), allocatable :: s4
    call allocate_array(s4)
    write(*,*) len(s4), size(s4)
 end program

gives the result:
           0          10
           0          10

when compiled with: gfortran -o stringtest stringtest.f90

but gives
           0          10
       32767          10

when using the -pg option.

Using -Wall does only show the following warning, which looks similar to that
in PR56670:

stringtest.f90: In function 'allocate_array':
stringtest.f90:7:0: warning: '.s_array' may be used uninitialized in this
function [-Wmaybe-uninitialized]
         write(*,*) len(s_array), size(s_array)
 ^


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

* [Bug fortran/60795] [4.7/4.8/4.9 Regression] Wrong length when allocating character array
  2014-04-09 15:00 [Bug fortran/60795] New: Wrong length when allocating character array kergonath at me dot com
                   ` (3 preceding siblings ...)
  2014-04-10  9:30 ` kergonath at me dot com
@ 2014-04-11  9:13 ` rguenth at gcc dot gnu.org
  2014-06-12 13:43 ` rguenth at gcc dot gnu.org
                   ` (5 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: rguenth at gcc dot gnu.org @ 2014-04-11  9:13 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P3                          |P4
   Target Milestone|---                         |4.7.4


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

* [Bug fortran/60795] [4.7/4.8/4.9 Regression] Wrong length when allocating character array
  2014-04-09 15:00 [Bug fortran/60795] New: Wrong length when allocating character array kergonath at me dot com
                   ` (4 preceding siblings ...)
  2014-04-11  9:13 ` rguenth at gcc dot gnu.org
@ 2014-06-12 13:43 ` rguenth at gcc dot gnu.org
  2014-07-10 19:10 ` [Bug fortran/60795] [4.8/4.9/4.10 " dominiq at lps dot ens.fr
                   ` (4 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: rguenth at gcc dot gnu.org @ 2014-06-12 13:43 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|4.7.4                       |4.8.4

--- Comment #5 from Richard Biener <rguenth at gcc dot gnu.org> ---
The 4.7 branch is being closed, moving target milestone to 4.8.4.


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

* [Bug fortran/60795] [4.8/4.9/4.10 Regression] Wrong length when allocating character array
  2014-04-09 15:00 [Bug fortran/60795] New: Wrong length when allocating character array kergonath at me dot com
                   ` (5 preceding siblings ...)
  2014-06-12 13:43 ` rguenth at gcc dot gnu.org
@ 2014-07-10 19:10 ` dominiq at lps dot ens.fr
  2014-12-19 13:27 ` [Bug fortran/60795] [4.8/4.9/5 " jakub at gcc dot gnu.org
                   ` (3 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: dominiq at lps dot ens.fr @ 2014-07-10 19:10 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|[4.8/4.9 Regression] Wrong  |[4.8/4.9/4.10 Regression]
                   |length when allocating      |Wrong length when
                   |character array             |allocating character array

--- Comment #6 from Dominique d'Humieres <dominiq at lps dot ens.fr> ---
Still present in 4.10 r212433, adjusting the summary.


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

* [Bug fortran/60795] [4.8/4.9/5 Regression] Wrong length when allocating character array
  2014-04-09 15:00 [Bug fortran/60795] New: Wrong length when allocating character array kergonath at me dot com
                   ` (6 preceding siblings ...)
  2014-07-10 19:10 ` [Bug fortran/60795] [4.8/4.9/4.10 " dominiq at lps dot ens.fr
@ 2014-12-19 13:27 ` jakub at gcc dot gnu.org
  2015-06-23  8:19 ` [Bug fortran/60795] [4.8/4.9/5/6 " rguenth at gcc dot gnu.org
                   ` (2 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: jakub at gcc dot gnu.org @ 2014-12-19 13:27 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|4.8.4                       |4.8.5

--- Comment #7 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
GCC 4.8.4 has been released.


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

* [Bug fortran/60795] [4.8/4.9/5/6 Regression] Wrong length when allocating character array
  2014-04-09 15:00 [Bug fortran/60795] New: Wrong length when allocating character array kergonath at me dot com
                   ` (7 preceding siblings ...)
  2014-12-19 13:27 ` [Bug fortran/60795] [4.8/4.9/5 " jakub at gcc dot gnu.org
@ 2015-06-23  8:19 ` rguenth at gcc dot gnu.org
  2015-06-26 19:56 ` [Bug fortran/60795] [4.9/5/6 " jakub at gcc dot gnu.org
  2015-06-26 20:28 ` jakub at gcc dot gnu.org
  10 siblings, 0 replies; 12+ messages in thread
From: rguenth at gcc dot gnu.org @ 2015-06-23  8:19 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|4.8.5                       |4.9.3

--- Comment #8 from Richard Biener <rguenth at gcc dot gnu.org> ---
The gcc-4_8-branch is being closed, re-targeting regressions to 4.9.3.


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

* [Bug fortran/60795] [4.9/5/6 Regression] Wrong length when allocating character array
  2014-04-09 15:00 [Bug fortran/60795] New: Wrong length when allocating character array kergonath at me dot com
                   ` (8 preceding siblings ...)
  2015-06-23  8:19 ` [Bug fortran/60795] [4.8/4.9/5/6 " rguenth at gcc dot gnu.org
@ 2015-06-26 19:56 ` jakub at gcc dot gnu.org
  2015-06-26 20:28 ` jakub at gcc dot gnu.org
  10 siblings, 0 replies; 12+ messages in thread
From: jakub at gcc dot gnu.org @ 2015-06-26 19:56 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #9 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
GCC 4.9.3 has been released.


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

* [Bug fortran/60795] [4.9/5/6 Regression] Wrong length when allocating character array
  2014-04-09 15:00 [Bug fortran/60795] New: Wrong length when allocating character array kergonath at me dot com
                   ` (9 preceding siblings ...)
  2015-06-26 19:56 ` [Bug fortran/60795] [4.9/5/6 " jakub at gcc dot gnu.org
@ 2015-06-26 20:28 ` jakub at gcc dot gnu.org
  10 siblings, 0 replies; 12+ messages in thread
From: jakub at gcc dot gnu.org @ 2015-06-26 20:28 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|4.9.3                       |4.9.4


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

end of thread, other threads:[~2015-06-26 20:28 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-04-09 15:00 [Bug fortran/60795] New: Wrong length when allocating character array kergonath at me dot com
2014-04-09 17:08 ` [Bug fortran/60795] [4.7/4.8/4.9 Regression] " dominiq at lps dot ens.fr
2014-04-09 18:38 ` kargl at gcc dot gnu.org
2014-04-10  0:25 ` quantheory at gmail dot com
2014-04-10  9:30 ` kergonath at me dot com
2014-04-11  9:13 ` rguenth at gcc dot gnu.org
2014-06-12 13:43 ` rguenth at gcc dot gnu.org
2014-07-10 19:10 ` [Bug fortran/60795] [4.8/4.9/4.10 " dominiq at lps dot ens.fr
2014-12-19 13:27 ` [Bug fortran/60795] [4.8/4.9/5 " jakub at gcc dot gnu.org
2015-06-23  8:19 ` [Bug fortran/60795] [4.8/4.9/5/6 " rguenth at gcc dot gnu.org
2015-06-26 19:56 ` [Bug fortran/60795] [4.9/5/6 " jakub at gcc dot gnu.org
2015-06-26 20:28 ` jakub 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).