http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57697

            Bug ID: 57697
           Summary: Segfault with defined assignment for components during
                    intrinsic assignment
           Product: gcc
           Version: 4.9.0
            Status: UNCONFIRMED
          Keywords: wrong-code
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: burnus at gcc dot gnu.org

Found with ForTrilinos's ForTrilinos_ADT_3D_Burgers_6th_Pade example.

For the code:
  function new_scalar_field(initial,comm) result(this)
    ...
    if (.not. allocated(map)) then
      map = Epetra_Map(NumGlobalElements,NumMyElements,IndexBase,comm)

gfortran generates the code:

  static struct epetra_map * _F.DA104 = 0B;
  static struct universal _F.DA105;
  ...
        if (map == 0B)
          {
            {
              static integer(kind=4) C.5077 = 1;
              static integer(kind=4) C.5076 = 4096;

              if (_F.DA104 != 0B) goto L.249;
              _F.DA104 = (struct epetra_map *) __builtin_malloc (56);
              L.249:;
              *_F.DA104 = create_linear (&C.5076, &nummyelements, &C.5077,
                           (struct __class_fepetra_comm_Epetra_comm *) comm);
            }
            _F.DA105 = map->epetra_blockmap.universal;
            if (map != 0B) goto L.251;
            map = (struct epetra_map *) __builtin_malloc (56);
            L.251:;
            *map = *_F.DA104;

Note that the assignment to "_F.DA105" dereferences "map", which is known to be
NULL!

Reply via email to