https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65024 Bug ID: 65024 Summary: Internal compiler error (gfortran) concerning unlimited polymorphic pointer Product: gcc Version: 4.9.2 Status: UNCONFIRMED Severity: normal Priority: P3 Component: fortran Assignee: unassigned at gcc dot gnu.org Reporter: matt at gneilson dot plus.com Created attachment 34732 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=34732&action=edit Sample program that produces the referenced internal compiler error. As explained in the GNU Fortran mailing list (see http://gcc.gnu.org/ml/fortran/2015-02/msg00047.html ). Please find attached some annotated sample code ('test.f90') that produces the error in question. The compiler seems to have trouble with the subroutine that I've named 'BUG' (lines 37-50); more specifically, the compiler appears to be complaining about line 48 (which I have labelled line "C"). The 'BUG' subroutine calls the subroutine named 'NEXT' to associate the 'e' pointer with a piece of preallocated memory, and then points the unlimited polymorphic 'e%info' variable to the piece of memory associated with the pointer 'p'. Attempting to compile the code as-is produces the following output: ### Beginning of Terminal output ### matt$ gfortran -v -save-temps -o test test.f90 Driving: gfortran -mmacosx-version-min=10.10.1 -v -save-temps -o test test.f90 -l gfortran -shared-libgcc Using built-in specs. COLLECT_GCC=gfortran COLLECT_LTO_WRAPPER=/usr/local/libexec/gcc/x86_64-apple-darwin14.0.0/4.9.2/lto-wrapper Target: x86_64-apple-darwin14.0.0 Configured with: ../gcc-4.9-20141029/configure --enable-languages=c++,fortran Thread model: posix gcc version 4.9.2 20141029 (prerelease) (GCC) COLLECT_GCC_OPTIONS='-mmacosx-version-min=10.10.1' '-v' '-save-temps' '-o' 'test' '-shared-libgcc' '-mtune=core2' /usr/local/libexec/gcc/x86_64-apple-darwin14.0.0/4.9.2/f951 test.f90 -fPIC -quiet -dumpbase test.f90 -mmacosx-version-min=10.10.1 -mtune=core2 -auxbase test -version -fintrinsic-modules-path /usr/local/lib/gcc/x86_64-apple-darwin14.0.0/4.9.2/finclude -o test.s GNU Fortran (GCC) version 4.9.2 20141029 (prerelease) (x86_64-apple-darwin14.0.0) compiled by GNU C version 4.9.2 20141029 (prerelease), GMP version 6.0.0, MPFR version 3.1.2-p10, MPC version 1.0.2 GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072 GNU Fortran (GCC) version 4.9.2 20141029 (prerelease) (x86_64-apple-darwin14.0.0) compiled by GNU C version 4.9.2 20141029 (prerelease), GMP version 6.0.0, MPFR version 3.1.2-p10, MPC version 1.0.2 GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072 test.f90: In function ‘bug’: test.f90:48:0: internal compiler error: in gfc_conv_component_ref, at fortran/trans-expr.c:1660 e%info => p ! line "C" ^ test.f90:48:0: internal compiler error: Abort trap: 6 gfortran: internal compiler error: Abort trap: 6 (program f951) Abort trap: 6 ### End of Terminal output ### Oddly enough, the code compiles without error if I comment-out the call to 'NEXT' (line 42, which I've labelled line "A") and uncomment lines 43-45 (which I've labelled lines "B_1", "B_2", and "B_3"), even though the 'NEXT' subroutine contains *exactly* the same content as lines 43-45. Andre Vehreschild responded to my post on the GNU Fortran mailing list, and he recommended that I add the following information: "When translating the pointer assignment in the select type the backend_decl of the _vptr's component-ref is not initialized (== NULL), leading to the crash experienced here. I haven't encountered something similar yet, therefore I can only guess: Something going wrong in the resolve-stage?" >From gcc-bugs-return-476900-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Wed Feb 11 18:03:20 2015 Return-Path: Delivered-To: listarch-gcc-bugs@gcc.gnu.org Received: (qmail 6559 invoked by alias); 11 Feb 2015 18:03:20 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org Delivered-To: mailing list gcc-bugs@gcc.gnu.org Received: (qmail 6419 invoked by uid 48); 11 Feb 2015 18:03:15 -0000 From: "fkrogh#gcc at mathalacarte dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug fortran/65025] New: Internal compiler error with preprocessor in gfortran Date: Wed, 11 Feb 2015 18:03:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: fortran X-Bugzilla-Version: 4.9.2 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: fkrogh#gcc at mathalacarte dot com X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter attachments.created Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-SW-Source: 2015-02/txt/msg01233.txt.bz2 Content-length: 783 https://gcc.gnu.org/bugzilla/show_bug.cgi?ide025 Bug ID: 65025 Summary: Internal compiler error with preprocessor in gfortran Product: gcc Version: 4.9.2 Status: UNCONFIRMED Severity: normal Priority: P3 Component: fortran Assignee: unassigned at gcc dot gnu.org Reporter: fkrogh#gcc at mathalacarte dot com Created attachment 34733 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id4733&actioníit Short program that gives the internal compiler error Compile the attached with gfortran -Dplet_=\'d\' -g -o test test.F90 or replace the d with s, q, or nonsense. The kind of preprocessor code used here seems to be handled just fine in the case of C code for gcc.