Summary: | [4.6 Regression] reallocation of array during constructor assignement | ||
---|---|---|---|
Product: | gcc | Reporter: | Kacper Kowalik <xarthisius.kk> |
Component: | fortran | Assignee: | Not yet assigned to anyone <unassigned> |
Status: | RESOLVED INVALID | ||
Severity: | normal | CC: | burnus, burnus, kargls, pault |
Priority: | P3 | ||
Version: | 4.6.0 | ||
Target Milestone: | --- | ||
Host: | Target: | ||
Build: | Known to work: | ||
Known to fail: | Last reconfirmed: | ||
Attachments: | test program to reproduce bug |
Description
Kacper Kowalik
2011-03-10 12:04:58 UTC
> Assigning [...] constructor to allocatable array changes size of that array, if > size([...]) is not equal to size(array) As far as I understand "reallocation on assignment, this is the expected behavior (default that you can override with -fno-realloc-lhs). There may be a missing error in [macbook] f90/bug% gfc -fno-realloc-lhs -fcheck=all pr48058.f90 [macbook] f90/bug% a.out 3 3 where a length 2 vector is assigned to a length 3 one(?). Somehow, I've missed this in ChangeLog. Sorry for the noise (In reply to comment #2) > Somehow, I've missed this in ChangeLog. Sorry for the noise ChangeLog is a horrible place to look at the new features in gfortran. It would be better to look on the gfortran wiki. http://gcc.gnu.org/wiki/GFortran#news Created attachment 26770 [details]
test program to reproduce bug
Robert Hayward wrote in comment #4: > Created attachment 26770 [details] > test program to reproduce bug Please do not attach test cases to random bugreports! But create a new bug report and put more information in the report. -- Except that both issues are related to Fortran 2003's (re)allocation on intrinsic assignment, they do not have anything in common. The issue of comment 4 / Robert Hayward's issue is a bug in gfortran 4.6/4.7, which has been been reported in PR 52012 and fixed around 2012-01-31. Please try a newer version of GCC 4.6/4.7 - or use -fno-realloc-lhs as work around. (The issue in comment 0 is a bug in the original reporter's program for Fortran 90/95: The shape on the right and on the left have to be the same. The proper assignment should have been one of the following: ivec(1:2) = [1,2] ivec(2:3) = [1,2] ivec(1:2:2) = [1,2] ! or ivec([1,3]) = [1,2] With Fortran 2003, the program became valid - as the compiler reallocated "ivec" with the shape of the right side. With -std=f95 or if the left-hand side weren't allocatable, -fcheck=bounds had given a run-time error.) 48058(In reply to comment #4) > Created attachment 26770 [details] > test program to reproduce bug Sorry about that, attached to the wrong bug. It was meant for 52151. |