From patchwork Tue Oct 18 23:48:49 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jerry DeLisle X-Patchwork-Id: 78145 Delivered-To: patch@linaro.org Received: by 10.140.97.247 with SMTP id m110csp1132047qge; Tue, 18 Oct 2016 16:49:28 -0700 (PDT) X-Received: by 10.98.95.193 with SMTP id t184mr5200474pfb.85.1476834568738; Tue, 18 Oct 2016 16:49:28 -0700 (PDT) Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id r133si34308849pgr.239.2016.10.18.16.49.28 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 18 Oct 2016 16:49:28 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-return-438968-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org; spf=pass (google.com: domain of gcc-patches-return-438968-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-438968-patch=linaro.org@gcc.gnu.org DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:to:cc :from:subject:message-id:date:mime-version:content-type; q=dns; s=default; b=TOrCQPS6w3rGezgUs3Yc8MFFsKjw8Sq8yXTX8rShkcaxsoE3es VaQevKjETbDzjifTVFoxtgJvVUbueUrwsezh1ZDgT1mdV/5MDDNkBx5rlCXzafM0 8SxrzCrTJmvb17/n5tndiC1HrjjPj1Ty3hW6DQ0g/Xa4J7degfqXkOwQw= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:to:cc :from:subject:message-id:date:mime-version:content-type; s= default; bh=qCawmbxoSK8c3D0D/gpC8JuHg80=; b=kVJUtbXDTl5RNay9TLSH X2gMbT8cbdj4/sMNGHVZj9UgdWplls/y6JKWI4I5Y6LGsaZz19pNtabX9xJ4ZGoj v6dXyFB7gCe6XKcGN1IpcXa+FQFUQJCmCg9lcs7OA7y2/FYSQhOyHDqiLpPY5FNt hDXcMvQRUEkEpn8uTxgo2mE= Received: (qmail 10723 invoked by alias); 18 Oct 2016 23:49:14 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 10688 invoked by uid 89); 18 Oct 2016 23:49:11 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.8 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_NONE, RCVD_IN_SORBS_SPAM, RP_MATCHES_RCVD, SPF_PASS autolearn=no version=3.3.2 spammy=AGE, CURRENT, caution, 103, 7 X-Spam-User: qpsmtpd, 2 recipients X-HELO: mtaout001-public.msg.strl.va.charter.net Received: from mtaout001-public.msg.strl.va.charter.net (HELO mtaout001-public.msg.strl.va.charter.net) (68.114.190.26) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 18 Oct 2016 23:48:56 +0000 Received: from impout006 ([68.114.189.21]) by mtaout001.msg.strl.va.charter.net (InterMail vM.9.00.023.01 201-2473-194) with ESMTP id <20161018234850.MSCS7355.mtaout001.msg.strl.va.charter.net@impout006>; Tue, 18 Oct 2016 18:48:50 -0500 Received: from amda8.localdomain ([96.41.215.23]) by impout006 with charter.net id xBop1t0050Wrkg001Bop6k; Tue, 18 Oct 2016 18:48:50 -0500 X-Authority-Analysis: v=2.1 cv=X+rcKQje c=1 sm=1 tr=0 a=salB9WdMPIDduBH7JsZfrA==:117 a=salB9WdMPIDduBH7JsZfrA==:17 a=L9H7d07YOLsA:10 a=9cW_t1CCXrUA:10 a=s5jvgZ67dGcA:10 a=r77TgQKjGQsHNAKrUKIA:9 a=mDV3o1hIAAAA:8 a=nN0cKP0puQOqp3sVJuIA:9 a=QEXdDO2ut3YA:10 a=7M5n0iw_GOPFNT93jkwA:9 a=_TlARmR1CkG7Z71l:21 a=2ov3JUVVWbz8vbjL:21 a=wh147d23D_2AcINl0YMA:9 a=LtBpFliifXMA:10 a=_FVE-zBwftR9WsbkzFJk:22 X-Auth-id: anZkZWxpc2xlQGNoYXJ0ZXIubmV0 To: "fortran@gcc.gnu.org" Cc: GCC Patches From: Jerry DeLisle Subject: [patch, fortran] PR77828 Linking gfortran-7 compiled program with libgfortran of 5.x allowed but crashes Message-ID: <5b9b6674-bad2-2db6-074d-62e6287001f4@charter.net> Date: Tue, 18 Oct 2016 16:48:49 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.3.0 MIME-Version: 1.0 Hi Folks, The attached patch does some minor cleanup and bumps the libgfortran version number. I have wanted to reorder the dtp structure for many years now. Not strictly needed but it has bugged me forever. The bump is needed because of the significant changes from implementation of DTIO. I also took care of the stream I/O TODO and added a new test case for the error message. On my system, I have LD_LIBRARY_PATH set to point to the new library version first and then the version 3 are found elsewhere. With the patch we now see the following behavior. (Test case in the PR) Compile with version 6. Finds libgfortran3 on execution: $gfc6 pr77828.f90 $ ./a.out Greetings from i 42 of 43 Greetings from i 42 of 43 Compile with version 7. Finds libgfortran4 on execution: $ gfc pr77828.f90 [jerry@amda8 pr77828]$ ./a.out Greetings from i 42 of 43 Greetings from i 42 of 43 Change LD_LIBRARY_PATH to not find libgfortran4: $ export LD_LIBRARY_PATH=/home/jerry/dev/usr6/lib64 $ gfc pr77828.f90 $ ./a.out ./a.out: error while loading shared libraries: libgfortran.so.4: cannot open shared object file: No such file or directory Word of caution. When this patch is applied rebuild from a clean/empty build directory. You must delete any libgfortran3 remnants that may have been built and installed previously with gcc version 7 trunk, Otherwise the linker/loader may find those rather than a libgfortran3 built for gcc 6 or previous. (When compiling with a previous version of gcc) New test case provided for the streamio error check. Regression tested on x86-64-linux. OK for trunk? Regards, Jerry 2016-10-18 Jerry DeLisle PR fortran/77828 * io/io.h (st_parameter_dt): Reorder for readability and sanity. * io/transfer.c (data_transfer_init): Remove TODO and enable the runtime error message, rec= specifier not allowed in STREAM access. * libtool-version: Bump major version of libgfortran to 4. 2016-10-18 Jerry DeLisle PR fortran/77828 * ioparm.def: Reorder dt parameters to match libgfortran. diff --git a/gcc/fortran/ioparm.def b/gcc/fortran/ioparm.def index 17b7ac78..bd628ce2 100644 --- a/gcc/fortran/ioparm.def +++ b/gcc/fortran/ioparm.def @@ -90,11 +90,9 @@ IOPARM (inquire, id, 1 << 7, pint4) IOPARM (inquire, iqstream, 1 << 8, char1) IOPARM (wait, common, 0, common) IOPARM (wait, id, 1 << 7, pint4) -#ifndef IOPARM_dt_list_format +IOPARM (dt, common, 0, common) #define IOPARM_dt_list_format (1 << 7) #define IOPARM_dt_namelist_read_mode (1 << 8) -#endif -IOPARM (dt, common, 0, common) IOPARM (dt, rec, 1 << 9, intio) IOPARM (dt, size, 1 << 10, pintio) IOPARM (dt, iolength, 1 << 11, pintio) @@ -103,7 +101,6 @@ IOPARM (dt, format, 1 << 12, char1) IOPARM (dt, advance, 1 << 13, char2) IOPARM (dt, internal_unit, 1 << 14, char1) IOPARM (dt, namelist_name, 1 << 15, char2) -IOPARM (dt, u, 0, pad) IOPARM (dt, id, 1 << 16, pint4) IOPARM (dt, pos, 1 << 17, intio) IOPARM (dt, asynchronous, 1 << 18, char1) @@ -115,3 +112,4 @@ IOPARM (dt, round, 1 << 23, char2) IOPARM (dt, sign, 1 << 24, char1) #define IOPARM_dt_f2003 (1 << 25) #define IOPARM_dt_dtio (1 << 26) +IOPARM (dt, u, 0, pad) diff --git a/gcc/testsuite/gfortran.dg/streamio_17.f90 b/gcc/testsuite/gfortran.dg/streamio_17.f90 new file mode 100644 index 00000000..41fa0b98 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/streamio_17.f90 @@ -0,0 +1,12 @@ +! { dg-do run } +program stream_test +implicit none +integer :: ios +character(128) :: message +open(10, status='scratch', access='stream') +write (10, rec=1, iostat=ios, iomsg=message) "This is a test" ! +if (ios.ne.5001) call abort +if (message.ne. & + &"Record number not allowed for stream access data transfer") & + call abort +end program diff --git a/libgfortran/io/io.h b/libgfortran/io/io.h index edc520a9..cae2193b 100644 --- a/libgfortran/io/io.h +++ b/libgfortran/io/io.h @@ -424,6 +424,15 @@ typedef struct st_parameter_dt CHARACTER2 (advance); CHARACTER1 (internal_unit); CHARACTER2 (namelist_name); + GFC_INTEGER_4 *id; + GFC_IO_INT pos; + CHARACTER1 (asynchronous); + CHARACTER2 (blank); + CHARACTER1 (decimal); + CHARACTER2 (delim); + CHARACTER1 (pad); + CHARACTER2 (round); + CHARACTER1 (sign); /* Private part of the structure. The compiler just needs to reserve enough space. */ union @@ -440,7 +449,8 @@ typedef struct st_parameter_dt unit_blank blank_status; unit_sign sign_status; int scale_factor; - int max_pos; /* Maximum righthand column written to. */ + /* Maximum righthand column written to. */ + int max_pos; /* Number of skips + spaces to be done for T and X-editing. */ int skips; /* Number of spaces to be done for T and X-editing. */ @@ -522,15 +532,6 @@ typedef struct st_parameter_dt must be smaller or equal to this array. */ char pad[16 * sizeof (char *) + 32 * sizeof (int)]; } u; - GFC_INTEGER_4 *id; - GFC_IO_INT pos; - CHARACTER1 (asynchronous); - CHARACTER2 (blank); - CHARACTER1 (decimal); - CHARACTER2 (delim); - CHARACTER1 (pad); - CHARACTER2 (round); - CHARACTER1 (sign); } st_parameter_dt; diff --git a/libgfortran/io/transfer.c b/libgfortran/io/transfer.c index 1f46ca64..fa2ec7b3 100644 --- a/libgfortran/io/transfer.c +++ b/libgfortran/io/transfer.c @@ -3026,20 +3026,13 @@ data_transfer_init (st_parameter_dt *dtp, int read_flag) return; } - /* TODO: This is required to maintain compatibility between - 4.3 and 4.4 runtime. Remove when ABI changes from 4.3 */ - - if (is_stream_io (dtp)) - dtp->u.p.current_unit->strm_pos = dtp->rec; - - /* TODO: Un-comment this code when ABI changes from 4.3. if (dtp->u.p.current_unit->flags.access == ACCESS_STREAM) { generate_error (&dtp->common, LIBERROR_OPTION_CONFLICT, "Record number not allowed for stream access " "data transfer"); return; - } */ + } } /* Bugware for badly written mixed C-Fortran I/O. */ diff --git a/libgfortran/libtool-version b/libgfortran/libtool-version index f787e378..71219909 100644 --- a/libgfortran/libtool-version +++ b/libgfortran/libtool-version @@ -3,4 +3,4 @@ # This is a separate file so that version updates don't involve re-running # automake. # CURRENT:REVISION:AGE -3:0:0 +4:0:0