https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81898
Bug ID: 81898 Summary: Issue with polymorphic container class Product: gcc Version: 7.1.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: fortran Assignee: unassigned at gcc dot gnu.org Reporter: jdhughes at usgs dot gov Target Milestone: --- Created attachment 42006 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=42006&action=edit Offending code The attached code is a minimal example of a problem we have encountered compiling one of our software products with version 7.1.1. The compiled code returns the following: Program received signal SIGSEGV: Segmentation fault - invalid memory reference. Backtrace for this error: #0 0x10b7310bc #1 0x10b7308aa #2 0x7fffe6ebdb39 Segmentation fault: 11 when compiled with gfortran 7.1.1 2017062 on OSX from macports using the following fortran flags: -g -fcheck=all -fbacktrace -fbounds-check -O0 -Wall -Wextra -fno-strict-aliasing -fwrapv The code also fails on linux with GNU Fortran (Ubuntu 7.1.0-5ubuntu2~14.04) 7.1.0 using the following fortran flags -O2 -fbacktrace -ffpe-summary=overflow -ffpe-trap=overflow,zero,invalid The code runs successfully when compiled on ubuntu linux with the following: 4.9.4 5.4.1 20160904 6.3.0 20170519 The segmentation fault occurs after the program completes allocation and initialization of this%element(i)%obj on line 117 for each element and makes the call to a_rd on line 121. A segmentation fault does not occur if this%elements is defined as: type(Btype), pointer, dimensions(:) :: elements => null() and the code is modified to reflect the change to this%elements. Is this a bug in 7.1.1?