This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug fortran/58750] New: Allocate-on-assignment fails when using size(other_array) in the assignment statement
- From: "adam at aphirst dot karoo.co.uk" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Wed, 16 Oct 2013 17:06:28 +0000
- Subject: [Bug fortran/58750] New: Allocate-on-assignment fails when using size(other_array) in the assignment statement
- Auto-submitted: auto-generated
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58750
Bug ID: 58750
Summary: Allocate-on-assignment fails when using
size(other_array) in the assignment statement
Product: gcc
Version: 4.8.1
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: fortran
Assignee: unassigned at gcc dot gnu.org
Reporter: adam at aphirst dot karoo.co.uk
Created attachment 31019
--> http://gcc.gnu.org/bugzilla/attachment.cgi?id=31019&action=edit
The function to which I've isolated the problem
System: Arch Linux x86_64, GCC 4.8.1 20130725 (prerelease) from official repos
Compiler flags: -Wall -Wextra -std=f2008 -s -march=native (no other
optimizations)
OK, so I have a function in which I'm putting some integers into allocatable
arrays using the F2008 allocate-on-assignment features. I've attached to this
bug report the specific function that goes sour, while the whole module file
can be found at http://pastebin.com/0ZVtVEzX , where the offending lines are
277-278.
I've been trying to construct a minimal demonstration of this problem without
much success, but I'll detail why I think this is a problem:
I'm allocating-on-assignment an array "primes" from the other functions in my
module, and if I print its contents or size(primes) I get the correct values.
So far so good.
What I'm then doing is creating an array full of zeros that's the same size as
"primes", called "powers". I'm doing this via:
powers = [ ( 0, i=1,size(primes) ) ]
and this is where the problem shows itself. If I then print powers I get a
blank line, and if I print size(powers) I get 0 . This of course causes the
rest of the function to be gibberish.
I also get the problem if I for instance have an integer "the_size" which I set
to size(primes). Despite being able to print "the_size" and get the correct
number, trying to allocate "powers" via
[ ( 0, i=1,the_size ) ]
gives the same problem.
If, however, I instead allocate "powers" using a literal, i.e.
powers = [ ( 0, i=1,10 ) ]
then the allocate-on-assign seems to work correctly.
Obviously I can also manually call allocate() then powers=0, but I shouldn't
_have_ to do that...
Is this enough information for someone to reproduce my problem, or understand
what the issue could be? Like I say, I've tried to create from-scratch
something to demonstrate the problem, but I can't coax the behaviour out.