------- Comment #9 from burnus at gcc dot gnu dot org  2010-08-03 15:33 -------
Created an attachment (id=21377)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=21377&action=view)
Draft patch (for init-expr char constructors only)

Some notes (all the following is about character strings):

* The issue seems to be only initialization expressions (F2003 term; F2008:
constant expressions) - for normal assignments the value seems to be correctly
converted.

* Scalars seem to be OK as well.

* To handle are thus: Array constructors and array-valued PARAMETERs

a) The attached patch handles structure constructors - including those which
have elements which are PARAMETERs

b) TODO: Using the following is valid but gives the same ICE than constructors
with out the patch:
  character (len=5), parameter :: str(2) = [ "12345", "67890" ]
  Type (t) :: tt = t(str)

c) ICE/Invalid: The following invalid code segfaults in check_constructor as
"str" is not an initialization expression. (Not all constructors need to be,
this one does):

  character (len=5) :: str(2) = [ "12345", "67890" ]
  Type (t) :: tt = t((/ str /))

d) One could consider warning about truncation (with -Wcharacter-truncation) -
if the constructor contains literals which are too long - for parameters (also
for those in constructors) the warning becomes useful.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44857

Reply via email to