This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug fortran/51434] ICE with scalar init of an array parameter, used in DT default init with transfer
- From: "sgk at troutmask dot apl.washington.edu" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Tue, 06 Dec 2011 15:47:41 +0000
- Subject: [Bug fortran/51434] ICE with scalar init of an array parameter, used in DT default init with transfer
- Auto-submitted: auto-generated
- References: <bug-51434-4@http.gcc.gnu.org/bugzilla/>
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51434
--- Comment #5 from Steve Kargl <sgk at troutmask dot apl.washington.edu> 2011-12-06 15:47:41 UTC ---
On Tue, Dec 06, 2011 at 06:40:07AM +0000, andy.nelson at lanl dot gov wrote:
>
> character(c_char) :: raidnum(lenname) = &
> & (/ 'r','a','i','d','n','u','m',..... /)
>
> Is this what you thought I was trying to do?
> Is what I am trying to do actually
> legal (would tend to think so atm, since pgi and intel don't have similar
> problems)?
What does 'character(c_char)' above declare?
What you have is an array of strings with each
string having a length of c_char.
R424 char-selector is length-selector
or ( LEN = type-param-value ,
KIND = scalar-int-initialization-expr )
or ( type-param-value ,
[ KIND = ] scalar-int-initialization-expr )
or ( KIND = scalar-int-initialization-expr
[ , LEN =type-param-value ] )
R425 length-selector is ( [ LEN = ] type-param-value )
or * char-length [ , ]
Let nlen be the length and nknd the kind, you want to
have one of the following forms:
character(len=nlen, kind=nknd) ...
character(nlen, kind=nknd) ...
character(len=nlen, nknd) ...
character(nlen, nknd) ...
character(kind=nknd) ...
character(kind=nknd, len=nlen) ...
For your case, nlen=1 and nknd=c_char.
As shown by Tobias, even if you fix your declarations, your
code will fail.
PS: I suspect yor code works with ifort and pgi because
c_char is probably 1, default character kind is 1, and
these compilers only support a single character kind. So,
you accidentally get want you want.
PPS: Yes, I would use an ugly explicit array to do the
initializaton instead of transfer. First, the explicit
array is clear and easy to understand. Second, although
transfer should work, it is one ugly piece of code
under the hood.