From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 7196 invoked by alias); 22 Jul 2010 20:58:58 -0000 Received: (qmail 6938 invoked by uid 22791); 22 Jul 2010 20:58:55 -0000 X-SWARE-Spam-Status: No, hits=-0.2 required=5.0 tests=AWL,BAYES_00,DKIM_SIGNED,DKIM_VALID,FREEMAIL_ENVFROM_END_DIGIT,FREEMAIL_FROM X-Spam-Check-By: sourceware.org Received: from mail-wy0-f175.google.com (HELO mail-wy0-f175.google.com) (74.125.82.175) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 22 Jul 2010 20:58:50 +0000 Received: by wyb38 with SMTP id 38so1152255wyb.20 for ; Thu, 22 Jul 2010 13:58:47 -0700 (PDT) MIME-Version: 1.0 Received: by 10.227.145.20 with SMTP id b20mr2514981wbv.28.1279832323343; Thu, 22 Jul 2010 13:58:43 -0700 (PDT) Received: by 10.216.17.71 with HTTP; Thu, 22 Jul 2010 13:58:43 -0700 (PDT) In-Reply-To: <4C477930.5060702@net-b.de> References: <4C461784.5020801@net-b.de> <4C477930.5060702@net-b.de> Date: Thu, 22 Jul 2010 20:58:00 -0000 Message-ID: Subject: Re: [Patch, Fortran, OOP] PR 44962: [OOP] ICE with specification expression SIZE() From: Janus Weil To: Tobias Burnus Cc: gfortran , gcc-patches Content-Type: multipart/mixed; boundary=0016367fb5f50147ca048c002fcb Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org X-SW-Source: 2010-07/txt/msg01784.txt.bz2 --0016367fb5f50147ca048c002fcb Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-length: 2853 >>> Frankly, I do not quite understand the check. [...] >>> >> Well, in general array bounds are only required to be specification >> expressions (F08:R516-518). However, there is an additional >> constraint. In F03 it was: >> >> C542 (R511) An explicit-shape array whose bounds are not >> initialization expressions shall be a dummy argument, a function >> result, or an automatic array of a procedure. >> >> In F08 it is: >> >> C531 (R516) An explicit-shape-spec whose bounds are not constant express= ions shall appear only in a subprogram, derived type de finition, BLOCK con= struct, or interface body. >> > > Can you add a comment before the gfc_is_constant_expr to state what the > function is actually doing (e.g. checking for specification expressions > while taking additionally the given constraints into account.) Well, it's actually not checking for specification expressions (which is what gfc_specification_expr does), but it checks for constant expressions, which are defined in chapter 7.1.12 of F08. >> If I am interpreting the above restrictions correctly, then components >> had to have constant array bounds in F03, while in F08 they don't have >> to be constant. Is that right? > > Seems so, but I somehow do not understand how this is supposed to work; > probably somehow like: > > subroutine foo(n) > =A0type t > =A0 =A0integer :: a(n) > =A0end type t > ... > end Probably. > As you check for specification expressions, you cannot simply remove the > check. The reason is that check_specification_function excludes > intrinsic functions (cf. "specification function" in the standard). No. Firstly, in "gfc_is_constant_expr" we're not checking for specification expressions. Second, constant expressions can *only* contain intrinsic functions. I think a "specification function" is a special case of a "specification expression". AFAICS, specification expressions in general can of course include intrinsic functions. If one checks for constant expressions and demands that they have been simplified, I think one can really reject all EXPR_FUNCTIONS: A function in a constant expr must be intrinsic, and those should be simplified away to a constant already. And no, specification functions are not constant. Quite the opposite: They cannot be! In fact, 'check_specification_function' can be removed, since it is equivalent to 'external_spec_function', and is only used in this one place where it is completely inappropriate. > I do not think that one needs to exclude the random functions (who says > that the array size needs to be deterministic). Well, I think the intention of "constant expressions" is to be something which can be evaluated to a constant at *compile* time. This is not the case for non-deterministic random functions. I'm now regtesting the attached patch. Any further comments? Cheers, Janus --0016367fb5f50147ca048c002fcb Content-Type: application/octet-stream; name="pr44962_v4.diff" Content-Disposition: attachment; filename="pr44962_v4.diff" Content-Transfer-Encoding: base64 X-Attachment-Id: f_gby348we0 Content-length: 4901 SW5kZXg6IGdjYy9mb3J0cmFuL2FycmF5LmMKPT09PT09PT09PT09PT09PT09 PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09 PT09PQotLS0gZ2NjL2ZvcnRyYW4vYXJyYXkuYwkocmV2aXNpb24gMTYyMjgy KQorKysgZ2NjL2ZvcnRyYW4vYXJyYXkuYwkod29ya2luZyBjb3B5KQpAQCAt MzAyLDggKzMwMiw3IEBAIHJlc29sdmVfYXJyYXlfYm91bmQgKGdmY19leHBy ICplLCBpbnQgY2hlY2tfY29uc3RhCiAKICAgaWYgKGNoZWNrX2NvbnN0YW50 ICYmIGdmY19pc19jb25zdGFudF9leHByIChlKSA9PSAwKQogICAgIHsKLSAg ICAgIGdmY19lcnJvciAoIlZhcmlhYmxlICclcycgYXQgJUwgaW4gdGhpcyBj b250ZXh0IG11c3QgYmUgY29uc3RhbnQiLAotCQkgZS0+c3ltdHJlZS0+bi5z eW0tPm5hbWUsICZlLT53aGVyZSk7CisgICAgICBnZmNfZXJyb3IgKCJBcnJh eSBib3VuZCBhdCAlTCBtdXN0IGJlIGNvbnN0YW50IiwgJmUtPndoZXJlKTsK ICAgICAgIHJldHVybiBGQUlMVVJFOwogICAgIH0KIApJbmRleDogZ2NjL2Zv cnRyYW4vZXhwci5jCj09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09 PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0KLS0tIGdjYy9m b3J0cmFuL2V4cHIuYwkocmV2aXNpb24gMTYyMjgyKQorKysgZ2NjL2ZvcnRy YW4vZXhwci5jCSh3b3JraW5nIGNvcHkpCkBAIC04NjgsMzkgKzg2OCwxNCBA QCBkb25lOgogfQogCiAKLXN0YXRpYyBtYXRjaAotY2hlY2tfc3BlY2lmaWNh dGlvbl9mdW5jdGlvbiAoZ2ZjX2V4cHIgKmUpCi17Ci0gIGdmY19zeW1ib2wg KnN5bTsKLQotICBpZiAoIWUtPnN5bXRyZWUpCi0gICAgcmV0dXJuIE1BVENI X05POwotCi0gIHN5bSA9IGUtPnN5bXRyZWUtPm4uc3ltOwotCi0gIC8qIEY5 NSwgNy4xLjYuMjsgRjIwMDMsIDcuMS43ICAqLwotICBpZiAoc3ltCi0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