Summary: | Wrong value for _vtab for intrinsic types with CLASS(*): storage_size of class(*) gives wrong result | ||
---|---|---|---|
Product: | gcc | Reporter: | Vladimir Fuka <vladimir.fuka> |
Component: | fortran | Assignee: | Paul Thomas <pault> |
Status: | RESOLVED FIXED | ||
Severity: | normal | CC: | burnus, pault |
Priority: | P3 | Keywords: | wrong-code |
Version: | 4.8.2 | ||
Target Milestone: | --- | ||
Host: | Target: | ||
Build: | Known to work: | ||
Known to fail: | Last reconfirmed: | 2013-10-18 00:00:00 | |
Bug Depends on: | 58851, 58858 | ||
Bug Blocks: | |||
Attachments: |
Test case
Fix for the PR |
Description
Vladimir Fuka
2013-10-18 18:18:09 UTC
Confirmed. Patch: diff --git a/gcc/fortran/class.c b/gcc/fortran/class.c index be4959a..8d911bb 100644 --- a/gcc/fortran/class.c +++ b/gcc/fortran/class.c @@ -2504,5 +2504,7 @@ gfc_find_intrinsic_vtab (gfc_typespec *ts) else c->initializer = gfc_get_int_expr (gfc_default_integer_kind, - NULL, ts->kind); + NULL, + ts->type == BT_COMPLEX + ? 2*ts->kind : ts->kind); /* Add component _extends. */ Actually, that patch is wrong: The expected values are for KIND / REAL / COMPLEX 4 32 64 8 64 128 10 128 256 << 16 128 256 And the marked line one cannot get from the kind number. The proper way it use use target-memory.c's size_complex() - which is not publicly exported. There is gfc_element_size, but that operates on an expression and not on a type spec. Created attachment 31048 [details]
Test case
(In reply to Tobias Burnus from comment #3) > Created attachment 31048 [details] > Test case Tobias, Are you taking this one, or is this a low-lying bug that you are dangling under my nose :-) ? Cheers Paul Created attachment 31054 [details]
Fix for the PR
This combines a rather obvious fix with Tobias' testcase.
I'll submit tomorrow.
Paul
Author: burnus Date: Wed Oct 23 05:44:02 2013 New Revision: 203945 URL: http://gcc.gnu.org/viewcvs?rev=203945&root=gcc&view=rev Log: 2013-10-23 Tobias Burnus <burnus@net-b.de> PR fortran/58793 * interface.c (compare_parameter): Reject passing TYPE(*) to CLASS(*). 2013-10-23 Tobias Burnus <burnus@net-b.de> PR fortran/58793 * gfortran.dg/assumed_type_8.f90: New. Added: trunk/gcc/testsuite/gfortran.dg/assumed_type_8.f90 Modified: trunk/gcc/fortran/ChangeLog trunk/gcc/fortran/interface.c trunk/gcc/testsuite/ChangeLog (In reply to Paul Thomas from comment #5) > Created attachment 31054 [details] - Fix for the PR which was committed as follows. Comment 6 is about one side issue found during review; pending is a patch for another side issue: Holleriths. Author: pault Date: Tue Oct 22 04:40:57 2013 New Revision: 203915 URL: http://gcc.gnu.org/viewcvs?rev=203915&root=gcc&view=rev Log: 2013-10-22 Paul Thomas <pault@gcc.gnu.org> PR fortran 57893 * class.c : Include target-memory.h. (gfc_find_intrinsic_vtab) Build a minimal expression so that gfc_element_size can be used to obtain the storage size, rather that the kind value. 2013-10-22 Paul Thomas <pault@gcc.gnu.org> PR fortran 57893 * gfortran.dg/unlimited_polymorphic_13.f90 : New test. Added: trunk/gcc/testsuite/gfortran.dg/unlimited_polymorphic_13.f90 Modified: trunk/gcc/fortran/ChangeLog trunk/gcc/fortran/class.c trunk/gcc/testsuite/ChangeLog Fixed on trunk. Thanks for the patch Paul |