Development

NAVIGATION
CATEGORIES
REFERRENCE
LINKS
  • New: better diagnostic needed

    6 answers - 252 bytes - related search similar search Add To My Delicious Add To My Stumble Upon Add To My Google Mark Add To My Facebook Add To My Digg Add To My Reddit

    using GNU Fortran 95 (GCC) 4.1.0 20051126 (prerelease) with '-g -pedantic
    -std=f95', I get a bad / no diagnostic for the following invalid code:
    INTEGER, PARAMETER :: K(2)=1
    SELECT CASE(I)
    CASE(MAXLC(K,1))
    END SELECT
    END
  • No.1 | | 106 bytes | |

    Comment #1 from kargl at gcc dot gnu dot org 2005-11-27 03:52
    What broken here? Where are the details?
  • No.2 | | 1407 bytes | |

    Comment #2 from eedelman at gcc dot gnu dot org 2005-11-30 14:18
    (In reply to comment #1)
    What broken here? Where are the details?

    I wondered that as well for a while. The problem, IIUC is that the
    case-selector
    must be an initialization expression. I'm no language lawyer, but if I
    understand the F2003 (draft) standard, MAXLC(k,1), where 'k' is a PARAMETER,
    ought to be a perfectly valid initialization expression. The standard, section
    7.1.7, says on initialization expressions:

    "It is an expression in which each operation is intrinsic, and each primary is

    []

    (5) A reference to a transformational standard intrinsic function other than
    NULL, where each argument is an initialization expression,"

    MAXLC, is, AFAIK, a transformational standard intrinsic, and 'k' and 1 are,
    AFAIK, initialization expressions.

    It turns out, however, that the F95 standard has a slightly different
    definition
    of initialization expressions (in section 7.1.6.1); it seems that MAXLC is not
    allowed here. So it seems the code is still invalid F95, and we should give a
    warning/error message if strict F95 standard checking is requested. I must,
    however, say, that I find it a bit wierd that MAXLC isn't allowed in this
    context, so I'm not sure what to think here I leave this as unconfirmed
    for now.
  • No.3 | | 694 bytes | |

    Comment #3 from eedelman at gcc dot gnu dot org 2005-11-30 18:29
    (In reply to comment #2)
    context, so I'm not sure what to think here I leave this as unconfirmed
    for now.

    Ifort 8.1 reports the following error:

    In a CASE statement, the case-value must be a constant expression. [MAXLC]
    CASE(MAXLC(K,1))
    ^

    Which agrees with my interpretation of the F95 standard. And now when I
    actually try it in gfortran (:-)), I get an ICE:

    erik:~$ gfortran huj.f90
    huj.f90: In function 'MAIN__':
    huj.f90:1: internal compiler error: in gfc_conv_constant_to_tree, at
    fortran/trans-const.c:276

    Confirmed as 'ice-on-invalid'.
  • No.4 | | 859 bytes | |

    Comment #5 from fxcoudert at gcc dot gnu dot org 2006-05-12 21:18
    Well, the testcase is valid F2003 but not valid F95. We have to get it working
    (for F2003 mode), which probably means adding a simplification function for
    MAXLC. And the same is true for all the intrinsics allowed by F2003 in an
    initialization expression.

    But we also have to get it rejected in F95 mode, which means keeping an
    explicit list of the intrinsics that are allowed in initialization expressions
    in F95, under the rules of 7.1.6.1 (all subcases a to e of case #7). I see two
    options here: either we add a property for all intrinsics, define it in the
    list and use that (lots of changes and thinking) or we add a new function
    valid_intrinsic_in_init_expr(). I'd prefer the second option, and will be
    thinking of something along these lines.
  • No.5 | | 291 bytes | |

    Comment #6 from fxcoudert at gcc dot gnu dot org 2006-06-19 18:21
    Paul Thomas proposed a patch that fixes the F95 problem. We still need to write
    simplification routines to enable such code (which is valid F2003) to compile
    with gfortran. I don't have time for that right now.
  • No.6 | | 133 bytes | |

    --
    steven at gcc dot gnu dot org changed:
    What |Removed |Added
    Severity|normal |enhancement

Re: New: better diagnostic needed


max 4000 letters.
Your nickname that display:
In order to stop the spam: 2 + 1 =
QUESTION ON "Development"

EMSDN.COM