Bug 58851 - FAIL: gfortran.dg/unlimited_polymorphic_13.f90 -O0 execution test
Summary: FAIL: gfortran.dg/unlimited_polymorphic_13.f90 -O0 execution test
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: testsuite (show other bugs)
Version: 4.9.0
: P3 normal
Target Milestone: ---
Assignee: Paul Thomas
URL:
Keywords:
Depends on:
Blocks: 58793
  Show dependency treegraph
 
Reported: 2013-10-23 09:21 UTC by Andreas Schwab
Modified: 2014-03-17 09:25 UTC (History)
2 users (show)

See Also:
Host:
Target: i386-*-*, m68k-*-*
Build:
Known to work:
Known to fail:
Last reconfirmed: 2013-10-23 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Andreas Schwab 2013-10-23 09:21:19 UTC
The storage size of real(kind=10) is target-dependent.  On i386 and m68k it is 96, not 128.
Comment 1 Paul Thomas 2013-10-23 11:29:22 UTC
Oh dear, oh dear.... sorry about that.  I should have seen it coming.

I'll deal with it.

Cheers

Paul
Comment 2 Tobias Burnus 2013-10-23 15:44:05 UTC
How about the following (untested)? It has a bit less coverage but hopefully it is still sufficient. Additionally, it should be portable.

--- a/gcc/testsuite/gfortran.dg/unlimited_polymorphic_13.f90
+++ b/gcc/testsuite/gfortran.dg/unlimited_polymorphic_13.f90
@@ -20,0 +21,8 @@ contains
+    real(c1) :: rc1
+    real(c2) :: rc2
+    real(c3) :: rc3
+    real(c4) :: rc4
+    complex(c1) :: cc1
+    complex(c2) :: cc2
+    complex(c3) :: cc3
+    complex(c4) :: cc4
@@ -22,10 +30,14 @@ contains
-    select case (k)
-     case (4)
-      sz = 32*2
-     case (8)
-      sz = 64*2
-     case (10,16)
-      sz = 128*2
-     case default
-       call abort()
-    end select
+    if (k == c1) then
+      sz = storage_size(cc1)
+      if (sz /= 2*storage_size(rc1)) call abort()
+    elseif (k == c2) then
+      sz = storage_size(cc2)
+      if (sz /= 2*storage_size(rc2)) call abort()
+    elseif (k == c3) then
+      sz = storage_size(cc3)
+      if (sz /= 2*storage_size(rc3)) call abort()
+    elseif (k == c4) then
+      sz = storage_size(cc4)
+      if (sz /= 2*storage_size(rc4)) call abort()
+    endif
+    if (sz < 2) call abort()
Comment 3 paul.richard.thomas@gmail.com 2013-10-23 20:39:52 UTC
I had changed the testcase to:

! { dg-do run }
!
! PR fortran/58793
!
! Contributed by  Vladimir Fuka
!
! Had the wrong value for the storage_size for complex
!
module m
  use iso_fortran_env
  implicit none
  integer, parameter :: c1 = real_kinds(1)
  integer, parameter :: c2 = real_kinds(2)
  integer, parameter :: c3 = real_kinds(size(real_kinds)-1)
  integer, parameter :: c4 = real_kinds(size(real_kinds))
  real(c1) :: r1
  real(c2) :: r2
  real(c3) :: r3
  real(c4) :: r4
contains
 subroutine s(o, k)
    class(*) :: o
    integer :: k
    integer :: sz

    select case (k)
     case (4)
      sz = storage_size(r1)*2
     case (8)
      sz = storage_size(r2)*2
     case (10)
      sz = storage_size(r3)*2
     case (16)
      sz = storage_size(r4)*2
     case default
       call abort()
    end select

    if (storage_size(o) /= sz) call abort()
    select type (o)
      type is (complex(c1))
        if (storage_size(o) /= sz) call abort()
      type is (complex(c2))
        if (storage_size(o) /= sz) call abort()
      type is (complex(c3))
        if (storage_size(o) /= sz) call abort()
      type is (complex(c4))
        if (storage_size(o) /= sz) call abort()
    end select
  end subroutine s
end module m

program p
 use m
 call s((1._c1, 2._c1), c1)
 call s((1._c2, 2._c2), c2)
 call s((1._c3, 2._c3), c3)
 call s((1._c4, 2._c4), c4)
end program p

Is it not the case that the select type (o) is unnecessary for the test?

That is ' if (storage_size(o) /= sz) call abort()' is all that is needed?

Cheers

Paul

On 23 October 2013 17:44, burnus at gcc dot gnu.org
<gcc-bugzilla@gcc.gnu.org> wrote:
> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58851
>
> Tobias Burnus <burnus at gcc dot gnu.org> changed:
>
>            What    |Removed                     |Added
> ----------------------------------------------------------------------------
>                  CC|                            |burnus at gcc dot gnu.org
>
> --- Comment #2 from Tobias Burnus <burnus at gcc dot gnu.org> ---
> How about the following (untested)? It has a bit less coverage but hopefully it
> is still sufficient. Additionally, it should be portable.
>
> --- a/gcc/testsuite/gfortran.dg/unlimited_polymorphic_13.f90
> +++ b/gcc/testsuite/gfortran.dg/unlimited_polymorphic_13.f90
> @@ -20,0 +21,8 @@ contains
> +    real(c1) :: rc1
> +    real(c2) :: rc2
> +    real(c3) :: rc3
> +    real(c4) :: rc4
> +    complex(c1) :: cc1
> +    complex(c2) :: cc2
> +    complex(c3) :: cc3
> +    complex(c4) :: cc4
> @@ -22,10 +30,14 @@ contains
> -    select case (k)
> -     case (4)
> -      sz = 32*2
> -     case (8)
> -      sz = 64*2
> -     case (10,16)
> -      sz = 128*2
> -     case default
> -       call abort()
> -    end select
> +    if (k == c1) then
> +      sz = storage_size(cc1)
> +      if (sz /= 2*storage_size(rc1)) call abort()
> +    elseif (k == c2) then
> +      sz = storage_size(cc2)
> +      if (sz /= 2*storage_size(rc2)) call abort()
> +    elseif (k == c3) then
> +      sz = storage_size(cc3)
> +      if (sz /= 2*storage_size(rc3)) call abort()
> +    elseif (k == c4) then
> +      sz = storage_size(cc4)
> +      if (sz /= 2*storage_size(rc4)) call abort()
> +    endif
> +    if (sz < 2) call abort()
>
> --
> You are receiving this mail because:
> You are on the CC list for the bug.
> You are the assignee for the bug.
Comment 4 Tobias Burnus 2013-10-23 20:57:15 UTC
(In reply to paul.richard.thomas@gmail.com from comment #3)
> I had changed the testcase to:

... which is in the essential part the same. (I had a few more checks, but those do not really matter.)

> Is it not the case that the select type (o) is unnecessary for the test?
> That is ' if (storage_size(o) /= sz) call abort()' is all that is needed?

For this bug, yes. But I think checking that within SELECT TYPE the correct SIZE_OF is applied, doesn't harm. Thus, I think it is useful to have.

I leave committing the patch to you – I think either of our versions is fine.
Comment 5 paul.richard.thomas@gmail.com 2013-10-25 09:12:20 UTC
Dear Tobias,

I cannot get to the commit until Sunday night at earliest.  Thus, if
you can do it, that would be great. In fact, if you do that, I'll post
the fix for the hollerith nonsense on Sunday.

Cheers

Paul

On 23 October 2013 22:57, burnus at gcc dot gnu.org
<gcc-bugzilla@gcc.gnu.org> wrote:
> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58851
>
> --- Comment #4 from Tobias Burnus <burnus at gcc dot gnu.org> ---
> (In reply to paul.richard.thomas@gmail.com from comment #3)
>> I had changed the testcase to:
>
> ... which is in the essential part the same. (I had a few more checks, but
> those do not really matter.)
>
>> Is it not the case that the select type (o) is unnecessary for the test?
>> That is ' if (storage_size(o) /= sz) call abort()' is all that is needed?
>
> For this bug, yes. But I think checking that within SELECT TYPE the correct
> SIZE_OF is applied, doesn't harm. Thus, I think it is useful to have.
>
> I leave committing the patch to you – I think either of our versions is fine.
>
> --
> You are receiving this mail because:
> You are on the CC list for the bug.
> You are the assignee for the bug.
Comment 6 Andreas Schwab 2013-10-30 09:23:33 UTC
unlimited_polymorphic_13.f90:43.15:

      type is (complex(c2))
               1
unlimited_polymorphic_13.f90:45.15:

      type is (complex(c3))
               2
Error: CASE label at (1) overlaps with CASE label at (2)
Comment 7 paul.richard.thomas@gmail.com 2013-10-30 09:41:59 UTC
Oh damn! Tobias pointed this out to me and I didn't catch on to why
this could happen. I'll fix it tonight.

Sorry about that

Paul

On 30 October 2013 10:23, schwab@linux-m68k.org
<gcc-bugzilla@gcc.gnu.org> wrote:
> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58851
>
> --- Comment #6 from Andreas Schwab <schwab@linux-m68k.org> ---
> unlimited_polymorphic_13.f90:43.15:
>
>       type is (complex(c2))
>                1
> unlimited_polymorphic_13.f90:45.15:
>
>       type is (complex(c3))
>                2
> Error: CASE label at (1) overlaps with CASE label at (2)
>
> --
> You are receiving this mail because:
> You are on the CC list for the bug.
> You are the assignee for the bug.
Comment 8 Andreas Schwab 2013-11-02 22:16:11 UTC
Still broken.

(gdb) ptype r3
type = real(kind=8)
(gdb) ptype r4
type = real(kind=10)
Comment 9 Tobias Burnus 2013-11-04 18:39:40 UTC
(In reply to Andreas Schwab from comment #8)
> Still broken.
> (gdb) ptype r3
> type = real(kind=8)
> (gdb) ptype r4
> type = real(kind=10)

With the same error? That shouldn't be the case since the commit r204286. Can you re-check that it fails and you have that version or newer?
Comment 10 paul.richard.thomas@gmail.com 2013-11-04 19:13:40 UTC
Thanks Tobias,

I was completely perplexed by that - you beat me to the reply by 32 minutes :-)

Cheers

Paul

On 4 November 2013 19:39, burnus at gcc dot gnu.org
<gcc-bugzilla@gcc.gnu.org> wrote:
> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58851
>
> --- Comment #9 from Tobias Burnus <burnus at gcc dot gnu.org> ---
> (In reply to Andreas Schwab from comment #8)
>> Still broken.
>> (gdb) ptype r3
>> type = real(kind=8)
>> (gdb) ptype r4
>> type = real(kind=10)
>
> With the same error? That shouldn't be the case since the commit r204286. Can
> you re-check that it fails and you have that version or newer?
>
> --
> You are receiving this mail because:
> You are on the CC list for the bug.
> You are the assignee for the bug.
Comment 11 Andreas Schwab 2013-11-04 20:45:47 UTC
It aborts.
Comment 12 Tobias Burnus 2013-11-04 21:26:32 UTC
(In reply to Andreas Schwab from comment #11)
> It aborts.

Well, that's progress: It now compiles :-)  [Even if we could have this earlier.]

Regarding the run-time failure: Can you pin-point where it fails? Looking at the code, I don't see any obvious candidate for a failure.
Comment 13 Andreas Schwab 2013-11-04 22:21:26 UTC
     case (10)
      sz = storage_size(r3)*2
Comment 14 Andreas Schwab 2014-03-17 09:23:48 UTC
Author: schwab
Date: Mon Mar 17 09:23:15 2014
New Revision: 208612

URL: http://gcc.gnu.org/viewcvs?rev=208612&root=gcc&view=rev
Log:
PR testsuite/58851
* gfortran.dg/unlimited_polymorphic_13.f90: Properly compute
storage size.

Modified:
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/testsuite/gfortran.dg/unlimited_polymorphic_13.f90
Comment 15 Andreas Schwab 2014-03-17 09:25:25 UTC
.