[RFC, PATCH, fortran] PR fortran/60255 Deferred character length

Andre Vehreschild vehre@gmx.de
Thu Dec 18 18:42:00 GMT 2014


Hi all,

here is my next try on proposing a patch for the issue in pr60255. It took me
quite some time to understand the intricacies with handling variables
associated in a select type. I think I got most of the issues fixed now:

- Added generation of _len component for each unlimited polymorphic pointer.
- Removed (my own) _len component creation routine.
- Removed the double underscore in get_len_component().
- Associating an unlimited polymorphic entity to a deferred char array now lets
  the deferred char array use the actual string length from the '_len'
  component of the unlimited polymorphic entity for the charlen instead of the
  size component of the vptr.
- Removed: Generating a special vtab name for deferred strings. A deferred
  string assigned to the unlimited polymorphic entity is now stored as having 
  charlen zero again.
- Basic support for char array arrays (No stuttering here) in u-poly variables.

Bootstraps ok on x86_64-linux-gnu. Comparing regtests I get a difference in
unlimited_polymorphic_2.f90 that I don't understand yet. May be that is only,
because one error message disappeared.

Attached is the full patch for trunk and a delta patch for those of you who
already have my pr60255_3 added.

I don't provide a changelog entry yet, because I think review will find some
issues still to fix. So, comments welcome!

Regards,
	Andre

On Tue, 9 Dec 2014 14:16:05 +0100
Dominique d'Humières <dominiq@lps.ens.fr> wrote:

> Dear Andre,
> 
> The patch causes an ICE for the test gfortran.dg/unlimited_polymorphic_1.f03:
> 
> f951: internal compiler error: in gfc_add_component_ref, at
> fortran/class.c:236
> 
> f951: internal compiler error: Abort trap: 6
> gfc: internal compiler error: Abort trap: 6 (program f951)
> Abort
> 
> Reduced test for which the ICE is triggered by ‘len(w)'
> 
> MODULE m
> 
> contains
>   subroutine bar (arg, res)
>     class(*) :: arg
>     character(100) :: res
>     select type (w => arg)
>       type is (character(*))
>         write (res, '(I2)') len(w)
>     end select
>   end subroutine
> 
> END MODULE
> 
> Note that with your patch at
> https://gcc.gnu.org/ml/fortran/2014-08/msg00022.html, I get the same ICE for
> the Mikael’s test at https://gcc.gnu.org/ml/fortran/2014-08/msg00055.html
> (before your patch for pr60255, it used to give a wrong length: 80 instead of
> 20 AFAICR).
> 
> Note that the assert at fortran/class.c:236 is also triggered for pr61115.
> 
> Thanks for working on these issues,
> 
> Dominique
> 
> >> On 8 December 2014 at 18:38, Andre Vehreschild <vehre@gmx.de> wrote:
> >> Hi all,
> >> 
> >> please find attached a more elaborate patch for pr60255. I totally agree
> >> that my first attempt was just scratching the surface of the work needed.
> >> 
> >> This patch also is *not* complete, but because I am really new to gfortran
> >> patching, I don't want to present a final patch only to learn then, that I
> >> have violated design rules, common practice or the like. Therefore please
> >> comment and direct me to any sources/ideas to improve the patch.
> >> 
> >> Topic:
> >> The pr 60255 is about assigning a char array to an unlimited polymorphic
> >> entity. In the comments the concern about the lost length information is
> >> raised. The patch adds a _len component to the unlimited polymorphic entity
> >> (after _data and _vtab) and adds an assignment of the string length to _len
> >> when a string is pointer assigned to the unlimited poly entity.
> >> Furthermore is the intrinsic len(unlimited poly pointing to a string)
> >> resolved to give the _len component.
> >> 
> >> Yet missing:
> >> - assign _len component back to deferred char array length component
> >> - transport length along chains of unlimited poly entities, i.e., a => b;
> >> c => a where all objects are unlimited poly and b is a string.
> >> - allocate() in this context
> >> 
> >> Patch dependencies:
> >> none
> >> 
> >> Comments, concerns, candy welcome!
> >> 
> >> Regards,
> >>        Andre
> 
> 


-- 
Andre Vehreschild * Kreuzherrenstr. 8 * 52062 Aachen
Tel.: +49 241 9291018 * Email: vehre@gmx.de 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: delta_pr60255_3_4.patch
Type: text/x-patch
Size: 20721 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20141218/27380ffc/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: pr60255_4.patch
Type: text/x-patch
Size: 23795 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20141218/27380ffc/attachment-0001.bin>


More information about the Gcc-patches mailing list