public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/51055] New: deferred length character allocation: allocate(character(len=i)::s) rejected
@ 2011-11-09 12:09 jpr at csc dot fi
2011-11-09 13:18 ` [Bug fortran/51055] " burnus at gcc dot gnu.org
` (7 more replies)
0 siblings, 8 replies; 9+ messages in thread
From: jpr at csc dot fi @ 2011-11-09 12:09 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51055
Bug #: 51055
Summary: deferred length character allocation:
allocate(character(len=i)::s) rejected
Classification: Unclassified
Product: gcc
Version: 4.7.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: fortran
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: jpr@csc.fi
Hi,
I think the program below is valid, but rejected by gfortran
program a
character(len=:), allocatable :: s
integer :: i=10
allocate(character(len=i)::s)
end program a
gfortran -v -o s s.f90
Driving: gfortran -v -o s s.f90 -l gfortran -l m -shared-libgcc
Using built-in specs.
COLLECT_GCC=gfortran
COLLECT_LTO_WRAPPER=/home/wrk/jpr/gcc-4.7/bin/../libexec/gcc/i686-pc-linux-gnu/4.7.0/lto-wrapper
Target: i686-pc-linux-gnu
Configured with: ../gcc/configure --enable-languages=c,c++,fortran
--disable-bootstrap --prefix=/wrk/jpr/gcc-4.7 --with-gmp=/wrk/jpr/extralib
--with-mpfr=/wrk/jpr/extralib
Thread model: posix
gcc version 4.7.0 20110927 (experimental) (GCC)
COLLECT_GCC_OPTIONS='-v' '-o' 's' '-shared-libgcc' '-mtune=generic'
'-march=pentiumpro'
/home/wrk/jpr/gcc-4.7/bin/../libexec/gcc/i686-pc-linux-gnu/4.7.0/f951 s.f90
-quiet -dumpbase s.f90 -mtune=generic -march=pentiumpro -auxbase s -version
-fintrinsic-modules-path
/home/wrk/jpr/gcc-4.7/bin/../lib/gcc/i686-pc-linux-gnu/4.7.0/finclude -o
/tmp/cc1PUv7g.s
GNU Fortran (GCC) version 4.7.0 20110927 (experimental) (i686-pc-linux-gnu)
compiled by GNU C version 3.4.6 20060404 (Red Hat 3.4.6-11), GMP
version 4.3.1, MPFR version 2.4.1, MPC version 0.8
GGC heuristics: --param ggc-min-expand=30 --param ggc-min-heapsize=4096
GNU Fortran (GCC) version 4.7.0 20110927 (experimental) (i686-pc-linux-gnu)
compiled by GNU C version 3.4.6 20060404 (Red Hat 3.4.6-11), GMP
version 4.3.1, MPFR version 2.4.1, MPC version 0.8
GGC heuristics: --param ggc-min-expand=30 --param ggc-min-heapsize=4096
s.f90:4.25:
allocate(character(len=i)::s)
1
Error: Variable 'i' cannot appear in the expression at (1)
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug fortran/51055] deferred length character allocation: allocate(character(len=i)::s) rejected
2011-11-09 12:09 [Bug fortran/51055] New: deferred length character allocation: allocate(character(len=i)::s) rejected jpr at csc dot fi
@ 2011-11-09 13:18 ` burnus at gcc dot gnu.org
2011-11-10 8:14 ` jpr at csc dot fi
` (6 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: burnus at gcc dot gnu.org @ 2011-11-09 13:18 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51055
Tobias Burnus <burnus at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |burnus at gcc dot gnu.org
--- Comment #1 from Tobias Burnus <burnus at gcc dot gnu.org> 2011-11-09 12:45:25 UTC ---
I also think that it is valid. However, I think there is already some bugreport
about this issue.
Stupid workaround: Replace
allocate(character(len=i)::s)
by
s = repeat(' ', i)
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug fortran/51055] deferred length character allocation: allocate(character(len=i)::s) rejected
2011-11-09 12:09 [Bug fortran/51055] New: deferred length character allocation: allocate(character(len=i)::s) rejected jpr at csc dot fi
2011-11-09 13:18 ` [Bug fortran/51055] " burnus at gcc dot gnu.org
@ 2011-11-10 8:14 ` jpr at csc dot fi
2011-11-10 8:38 ` burnus at gcc dot gnu.org
` (5 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: jpr at csc dot fi @ 2011-11-10 8:14 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51055
--- Comment #2 from jpr at csc dot fi 2011-11-10 06:09:07 UTC ---
OK, i found and lost the PR that included this. However,
your workaround doesn't seem to work either:
program a
character(len=:),allocatable::s
integer::j=2
s=repeat(' ',j)
print*,len(s),len(repeat(' ',j))
end program a
gfortran -o a a.f90; ./a
2846708 2
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug fortran/51055] deferred length character allocation: allocate(character(len=i)::s) rejected
2011-11-09 12:09 [Bug fortran/51055] New: deferred length character allocation: allocate(character(len=i)::s) rejected jpr at csc dot fi
2011-11-09 13:18 ` [Bug fortran/51055] " burnus at gcc dot gnu.org
2011-11-10 8:14 ` jpr at csc dot fi
@ 2011-11-10 8:38 ` burnus at gcc dot gnu.org
2012-05-11 14:39 ` burnus at gcc dot gnu.org
` (4 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: burnus at gcc dot gnu.org @ 2011-11-10 8:38 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51055
Tobias Burnus <burnus at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |rejects-valid, wrong-code
Depends on| |45170
--- Comment #3 from Tobias Burnus <burnus at gcc dot gnu.org> 2011-11-10 08:20:12 UTC ---
(In reply to comment #2)
> However, your workaround doesn't seem to work either:
> s=repeat(' ',j)
Try: s = (repeat(' ', j)
I think the issue is somewhat covered in PR 45170 comment 14
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug fortran/51055] deferred length character allocation: allocate(character(len=i)::s) rejected
2011-11-09 12:09 [Bug fortran/51055] New: deferred length character allocation: allocate(character(len=i)::s) rejected jpr at csc dot fi
` (2 preceding siblings ...)
2011-11-10 8:38 ` burnus at gcc dot gnu.org
@ 2012-05-11 14:39 ` burnus at gcc dot gnu.org
2012-05-14 16:47 ` burnus at gcc dot gnu.org
` (3 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: burnus at gcc dot gnu.org @ 2012-05-11 14:39 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51055
--- Comment #4 from Tobias Burnus <burnus at gcc dot gnu.org> 2012-05-11 14:31:26 UTC ---
See http://gcc.gnu.org/ml/fortran/2012-05/msg00054.html
The problem is that the character length is used for reallocation before it is
set.
The following should work. The only question is whether it causes problems by
enabling not only REPEAT but all other functions.
Well, seemingly also other functions are affected. The following code has the
same problem.
The bug is also mentioned in:
PR 49110
PR 45170 comment 14 (mentioned there and in some other comments, but not the
bug)
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug fortran/51055] deferred length character allocation: allocate(character(len=i)::s) rejected
2011-11-09 12:09 [Bug fortran/51055] New: deferred length character allocation: allocate(character(len=i)::s) rejected jpr at csc dot fi
` (3 preceding siblings ...)
2012-05-11 14:39 ` burnus at gcc dot gnu.org
@ 2012-05-14 16:47 ` burnus at gcc dot gnu.org
2012-05-14 16:56 ` burnus at gcc dot gnu.org
` (2 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: burnus at gcc dot gnu.org @ 2012-05-14 16:47 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51055
--- Comment #5 from Tobias Burnus <burnus at gcc dot gnu.org> 2012-05-14 16:45:31 UTC ---
Author: burnus
Date: Mon May 14 16:45:16 2012
New Revision: 187472
URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=187472
Log:
2012-05-14 Tobias Burnus <burnus@net-b.de>
PR fortran/49110
PR fortran/51055
PR fortran/53329
* trans-expr.c (gfc_trans_assignment_1): Fix allocation
handling for assignment of function results to allocatable
deferred-length strings.
* trans-decl.c (gfc_create_string_length): For deferred-length
module variables, include module name in the assembler name.
(gfc_get_symbol_decl): Don't override the assembler name.
2012-05-14 Tobias Burnus <burnus@net-b.de>
PR fortran/49110
PR fortran/51055
PR fortran/53329
* gfortran.dg/deferred_type_param_4.f90: New.
* gfortran.dg/deferred_type_param_6.f90: New.
Added:
trunk/gcc/testsuite/gfortran.dg/deferred_type_param_4.f90
trunk/gcc/testsuite/gfortran.dg/deferred_type_param_6.f90
Modified:
trunk/gcc/fortran/ChangeLog
trunk/gcc/fortran/trans-decl.c
trunk/gcc/fortran/trans-expr.c
trunk/gcc/testsuite/ChangeLog
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug fortran/51055] deferred length character allocation: allocate(character(len=i)::s) rejected
2011-11-09 12:09 [Bug fortran/51055] New: deferred length character allocation: allocate(character(len=i)::s) rejected jpr at csc dot fi
` (4 preceding siblings ...)
2012-05-14 16:47 ` burnus at gcc dot gnu.org
@ 2012-05-14 16:56 ` burnus at gcc dot gnu.org
2012-05-23 20:36 ` burnus at gcc dot gnu.org
2012-05-23 20:46 ` burnus at gcc dot gnu.org
7 siblings, 0 replies; 9+ messages in thread
From: burnus at gcc dot gnu.org @ 2012-05-14 16:56 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51055
Tobias Burnus <burnus at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Last reconfirmed| |2012-05-14
Ever Confirmed|0 |1
--- Comment #6 from Tobias Burnus <burnus at gcc dot gnu.org> 2012-05-14 16:48:06 UTC ---
The REPEAT issue is now fixed. Thus, one can replace the work-around-around
"(repeat(...))" by the work-around "repeat(...)".
TODO: The issue shown in comment 0 and in the summary of this PR.
(Which is the same as PR 45170 comment 14. For quotes from the standard, see
that PR.)
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug fortran/51055] deferred length character allocation: allocate(character(len=i)::s) rejected
2011-11-09 12:09 [Bug fortran/51055] New: deferred length character allocation: allocate(character(len=i)::s) rejected jpr at csc dot fi
` (5 preceding siblings ...)
2012-05-14 16:56 ` burnus at gcc dot gnu.org
@ 2012-05-23 20:36 ` burnus at gcc dot gnu.org
2012-05-23 20:46 ` burnus at gcc dot gnu.org
7 siblings, 0 replies; 9+ messages in thread
From: burnus at gcc dot gnu.org @ 2012-05-23 20:36 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51055
--- Comment #7 from Tobias Burnus <burnus at gcc dot gnu.org> 2012-05-23 20:35:44 UTC ---
Author: burnus
Date: Wed May 23 20:35:30 2012
New Revision: 187811
URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=187811
Log:
2012-05-23 Tobias Burnus <burnus@net-b.de>
PR fortran/51055
PR fortran/45170
* match.c (gfc_match_allocate): Set length_from_typespec
for characters.
* resolve.c (resolve_charlen): If set, don't check whether
the len is a specification expression.
2012-05-23 Tobias Burnus <burnus@net-b.de>
PR fortran/51055
PR fortran/45170
* gfortran.dg/allocate_with_typespec_6.f90: New.
Added:
trunk/gcc/testsuite/gfortran.dg/allocate_with_typespec_6.f90
Modified:
trunk/gcc/fortran/ChangeLog
trunk/gcc/fortran/match.c
trunk/gcc/fortran/resolve.c
trunk/gcc/testsuite/ChangeLog
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug fortran/51055] deferred length character allocation: allocate(character(len=i)::s) rejected
2011-11-09 12:09 [Bug fortran/51055] New: deferred length character allocation: allocate(character(len=i)::s) rejected jpr at csc dot fi
` (6 preceding siblings ...)
2012-05-23 20:36 ` burnus at gcc dot gnu.org
@ 2012-05-23 20:46 ` burnus at gcc dot gnu.org
7 siblings, 0 replies; 9+ messages in thread
From: burnus at gcc dot gnu.org @ 2012-05-23 20:46 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51055
Tobias Burnus <burnus at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Resolution| |FIXED
--- Comment #8 from Tobias Burnus <burnus at gcc dot gnu.org> 2012-05-23 20:38:49 UTC ---
(In reply to comment #6)
> TODO: The issue shown in comment 0 and in the summary of this PR.
That's now also FIXED on the 4.8 trunk.
Thanks for the bug report - and sorry for taking half a year to get this fixed.
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2012-05-23 20:39 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-11-09 12:09 [Bug fortran/51055] New: deferred length character allocation: allocate(character(len=i)::s) rejected jpr at csc dot fi
2011-11-09 13:18 ` [Bug fortran/51055] " burnus at gcc dot gnu.org
2011-11-10 8:14 ` jpr at csc dot fi
2011-11-10 8:38 ` burnus at gcc dot gnu.org
2012-05-11 14:39 ` burnus at gcc dot gnu.org
2012-05-14 16:47 ` burnus at gcc dot gnu.org
2012-05-14 16:56 ` burnus at gcc dot gnu.org
2012-05-23 20:36 ` burnus at gcc dot gnu.org
2012-05-23 20:46 ` burnus 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).