From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 47805 invoked by alias); 7 Sep 2018 14:36:41 -0000 Mailing-List: contact fortran-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Post: List-Help: , Sender: fortran-owner@gcc.gnu.org Received: (qmail 47784 invoked by uid 89); 7 Sep 2018 14:36:40 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM,HTML_MESSAGE,RCVD_IN_DNSWL_NONE,SPF_PASS autolearn=ham version=3.3.2 spammy=HTo:U*janus, trailing, H*f:sk:CAJ3Baz, H*f:sk:ueZHDLK X-HELO: mail-it0-f44.google.com Received: from mail-it0-f44.google.com (HELO mail-it0-f44.google.com) (209.85.214.44) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 07 Sep 2018 14:36:38 +0000 Received: by mail-it0-f44.google.com with SMTP id j198-v6so22993283ita.0; Fri, 07 Sep 2018 07:36:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=oS3BwRSrsjxrFR4SWGkrC0mgRmxDZTOEjPI9ldk2DHI=; b=EuCrN1KeInSyvufgmshvd+cpcv8L/WVLI9wExT3F3nbg2CuP5pxVQiD7NBVO8FtYkA Us4kMHRfTisEfSWeVg6bWGnVo5pW51znvyqAXG7zaORDwZ68sZVtNToBppZerU/16bwC IbPsLKxpFaSlOf6IPCK7P1Sjyhgpmbziyi7CiuX8dGX9L43jVkSzHylmDCNiQR1Nz9a4 1ZNNr9oUUyVAQ5kvLjVFbvoEHHsjQJb7iecYChjon+86lKGq0SDU3j8Jq37M4FoVl8e4 sbhfoLhV1UyUIbVLl0CTRy5L6qRS9qHCDe3A8BBMqxAcYw06JkTJCcNjZW9gEMrcnGWt VKDQ== MIME-Version: 1.0 References: In-Reply-To: From: Ethan Beyak Date: Fri, 07 Sep 2018 14:36:00 -0000 Message-ID: Subject: Re: Assignment interfaces with allocatable polymorphic variables in gfortran 5.5.0 & 8.1.0. To: janus@gcc.gnu.org Cc: fortran@gcc.gnu.org Content-Type: text/plain; charset="UTF-8" X-IsSubscribed: yes X-SW-Source: 2018-09/txt/msg00079.txt.bz2 Janus, Thank you very much for your response. I didn't realize you could put an 'assignment (=)' in a public statement. This'll solve my problem perfectly! As a follow-up, let's say I did have multiple 'interface assignment (=)' blocks in this module. Would the 'public assignment (=)' statement then make all of assignments public then? Is there any way to make these 'public assignment (=)' statements distinct? I tried the following, both failed to compile on gfortran 5.5.0: ======= interface assign_foo assignment (=) module procedure foo end interface assign_foo assignment (=) interface assignment (=) assign_foo module procedure foo end interface assignment (=) assign_foo 'Error: Syntax error: Trailing garbage in INTERFACE statement' ======= Is there any way I could apply the public attribute to the interface block directly, or am I limited to public statements for affecting the accessibility of interface blocks? And a brief convention question: is it standard to omit whitespace between 'assignment' and '(=)' when writing Fortran, or is there no general consensus? Thanks, Ethan On Fri, Sep 7, 2018 at 5:56 AM Janus Weil wrote: > Hi Ethan, > > > However, on version 5.5, I get the following errors: > > > > OUTPUT 2 > > ========= > > $ gfortran --version > > GNU Fortran (Ubuntu 5.5.0-12ubuntu1) 5.5.0 20171010 > > > > $ gfortran baz_module.f90 test_public_assignment.f90 -o test.out > > test_public_assignment.f90:13:0: > > > > wrk = e ! invoking foo > > 1 > > Error: Assignment to an allocatable polymorphic variable at (1) is not > yet > > supported > > test_public_assignment.f90:19:0: > > Note that gfortran version 7 can also compile the program in its > original form (so you don't necessarily need version 8), but > unfortunately earlier versions fail. > > > > Now I did find some workaround by setting the default accessibility of > the > > module to be public and explicitly declaring the complement of the set of > > procedures and variables that I wanted to be private. I'm not sure what > > gfortran 5.5.0 is doing to be honest, but the definition of the > assignment > > can be used in the calling program. Commenting out lines 5,6 and > commenting > > in lines 8,9 in baz_module.f90 gave me the following output on gfortran > > 5.5.0 > > > > OUTPUT 3 > > ========= > > Compiler version: GCC version 5.5.0 20171010 > > Compiler options: -mtune=generic -march=x86-64 > > d: 4.00000000 2.00000000 1.00000000 > > e: 8.00000000 6.00000000 4.00000000 > > f: 32.0000000 18.0000000 8.00000000 > > ========= > > > > So I have two questions for the gfortran community: 1) do you know why > > inverting the module accessibility causes these assignments to work in > > gfortran 5.5.0? It seems as if the assignment interface was made public > > somehow, but I'm not certain. > > Exactly, the "public" statement makes everything in the module public > by default. The assignment operator is private otherwise. > > > > 2) can you think of any *clean* solutions to > > this problem? I'd love backward compatibility while not going against the > > recommended standard of private default accessibility. > > A more reasonable approach might be to not make everything public, but > just the assignment interface: > > public assignment(=) > > HTH, > Janus >