[Bug fortran/70842] [4.9/5/6/7 Regression] internal compiler error with character members within a polymorphic pointer

nathanael.huebbe at informatik dot uni-hamburg.de gcc-bugzilla@gcc.gnu.org
Thu Apr 28 16:33:00 GMT 2016


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70842

--- Comment #3 from nathanael.huebbe at informatik dot uni-hamburg.de ---
This is getting even nastier. As it turns out, even though the code I gave
above compiles, it does not produce correct results. To be precise, if I use a
routine like

    subroutine bar(me)
        class(t_Intermediate), pointer, intent(in) :: me
        class(*), pointer :: meAlias
        character(len = :), pointer :: textAlias

        meAlias => me

        select type(meAlias)
                type is(t_Foo)
                        textAlias => meAlias%string
                        print*, "'"//textAlias//"', len = ", len(textAlias)    
!OK
                        print*, "'"//meAlias%string//"', len = ",
len(meAlias%string)   !string ok, len = nonsense
        end select
    end subroutine

I get some completely wrong length in the second `print` statement (like
`152660480`), even though the string itself is output correctly. Again, the
indirection via an additional pointer produces correct results.

Another curious fact is, that the large number is constant across objects
within a single run, but different when I restart my program. So I'm willing to
speculate that somehow the vtable pointer is mistaken for the string length,
but that may be completely wrong.


More information about the Gcc-bugs mailing list