------- Comment #2 from tkoenig at gcc dot gnu dot org 2008-05-18 10:42 -------
The problem is with the array parameter.
$ cat spread.f90
implicit none
character(len=5), dimension(3,3), parameter :: &
p = reshape(["a", "b", "c", "d", "e", "f", "g", "h", "i"], [3,3])
character(len=5), dimension(3,3) :: m1
m1 = p
print '(18A)', spread (p, 1, 2)//"z"
print '(18A)', spread (m1, 1, 2)//"z"
end
$ gfortran -fdump-tree-original -g spread.f90
$ gdb ./a.out
Breakpoint 1 (_gfortran_spread_char) pending.
(gdb) r
Starting program: /tmp/a.out
Breakpoint 2 at 0xb7f69f13: file
../../../../gcc/trunk/libgfortran/intrinsics/spread_generic.c, line 421.
Pending breakpoint "_gfortran_spread_char" resolved
Breakpoint 2, *_gfortran_spread_char (ret=0xbfe7d7b8, ret_length=5,
source=0xbfe7d80c,
along=0x8048dd4, pncopies=0x8048dd0, source_length=5)
at ../../../../gcc/trunk/libgfortran/intrinsics/spread_generic.c:422
422 spread_internal (ret, source, along, pncopies, source_length);
(gdb) p *source
$1 = {data = 0xbfe7d827 "a b c ç¿\001", offset = 0, dtype = 369, dim =
{{
stride = 1, lbound = 0, ubound = 2}, {stride = 1627389952, lbound =
538976288,
ubound = 538976354}, {stride = 538993440, lbound = -1075372000, ubound =
1}, {
stride = 0, lbound = -1075324808, ubound = -1208419248}, {stride =
-1075324752,
lbound = -1209229152, ubound = -1075317768}, {stride = -1075324652,
lbound = -1075324808, ubound = 134515769}, {stride = 1, lbound =
-1075324652,
ubound = -1075324792}}}
This is seriously flawed. The data pointer is wrong, as is the dtype.
Using m1 is ok:
(gdb) c
Continuing.
a za zb zb zc zc z
Breakpoint 2, *_gfortran_spread_char (ret=0xbfe7d758, ret_length=5,
source=0xbfe7d7b8,
along=0x8048dd4, pncopies=0x8048dd0, source_length=5)
at ../../../../gcc/trunk/libgfortran/intrinsics/spread_generic.c:422
422 spread_internal (ret, source, along, pncopies, source_length);
(gdb) p *source
$2 = {data = 0xbfe7d78b "a b c d e f g h i
\213×ç¿üÿÿÿr\001",
offset = 4294967292, dtype = 370, dim = {{stride = 1, lbound = 1, ubound =
3}, {
stride = 3, lbound = 1, ubound = 3}, {stride = -1208504320, lbound =
543414304,
ubound = 2048925728}, {stride = -1075324928, lbound = 0, ubound = 0},
{stride = 1,
lbound = 0, ubound = 2}, {stride = 134516032, lbound = 134516037,
ubound = 134516042}, {stride = -1075324889, lbound = 0, ubound = 369}}}
--
tkoenig at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Summary|SPREAD gives wrong results |SPREAD gives wrong results
|with CHARACTER variables |with array CHARACTER
| |parameters
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36257