public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/66775] New: Allocatable function result type(t) produces segfault when uninitialized
@ 2015-07-06  9:26 vehre at gcc dot gnu.org
  2015-07-09 10:37 ` [Bug fortran/66775] " vehre at gcc dot gnu.org
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: vehre at gcc dot gnu.org @ 2015-07-06  9:26 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66775

            Bug ID: 66775
           Summary: Allocatable function result type(t) produces segfault
                    when uninitialized
           Product: gcc
           Version: 6.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: vehre at gcc dot gnu.org
  Target Milestone: ---

Created attachment 35917
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=35917&action=edit
Full pseudo code of failing example.

The following code produces a segfault:

! { dg-do run }

module test_alloc_func_mod
  implicit none

  type t
    integer :: i = 5
  end type

contains

  type(t) function t_init() ! { dg-warning "not set" }
    allocatable :: t_init
  end function

end module test_alloc_func_mod

program test_alloc_func
  use test_alloc_func_mod

  type(t), allocatable :: temp

  temp = t_init() ! <-- This derefs a null-pointer currently
  if (allocated (temp)) call abort()
end program


The pseudo code in question is:
t_init ()
{
  struct t * __result_t_init;

  __result_t_init = 0B;    // Setting NULL-pointer.
  return __result_t_init;
}

for t_init, and reduced to the essential line (full pseudo code is attached)

  struct t * temp;
  struct t * D.3388;
  temp = (struct t *) __builtin_malloc (4);
  D.3388 = t_init ();
  *temp = *D.3388;      // D.3388 is NULL; dereferencing it here is hazardous.

This error was experienced during patching of pr58586.


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug fortran/66775] Allocatable function result type(t) produces segfault when uninitialized
  2015-07-06  9:26 [Bug fortran/66775] New: Allocatable function result type(t) produces segfault when uninitialized vehre at gcc dot gnu.org
@ 2015-07-09 10:37 ` vehre at gcc dot gnu.org
  2015-07-09 10:38 ` vehre at gcc dot gnu.org
  2015-07-10  9:45 ` vehre at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: vehre at gcc dot gnu.org @ 2015-07-09 10:37 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66775

--- Comment #1 from vehre at gcc dot gnu.org ---
This bug is somehow related with 55603.


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug fortran/66775] Allocatable function result type(t) produces segfault when uninitialized
  2015-07-06  9:26 [Bug fortran/66775] New: Allocatable function result type(t) produces segfault when uninitialized vehre at gcc dot gnu.org
  2015-07-09 10:37 ` [Bug fortran/66775] " vehre at gcc dot gnu.org
@ 2015-07-09 10:38 ` vehre at gcc dot gnu.org
  2015-07-10  9:45 ` vehre at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: vehre at gcc dot gnu.org @ 2015-07-09 10:38 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66775

--- Comment #2 from vehre at gcc dot gnu.org ---
This bug is somehow related with pr55603.


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug fortran/66775] Allocatable function result type(t) produces segfault when uninitialized
  2015-07-06  9:26 [Bug fortran/66775] New: Allocatable function result type(t) produces segfault when uninitialized vehre at gcc dot gnu.org
  2015-07-09 10:37 ` [Bug fortran/66775] " vehre at gcc dot gnu.org
  2015-07-09 10:38 ` vehre at gcc dot gnu.org
@ 2015-07-10  9:45 ` vehre at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: vehre at gcc dot gnu.org @ 2015-07-10  9:45 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66775

vehre at gcc dot gnu.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|---                         |INVALID

--- Comment #3 from vehre at gcc dot gnu.org ---
By sections 12.5.3 and 12.6.2.2 of F2008 the function has to return an
allocated object, this means this pr is invalid. Nothing broken, nothing to
fix.


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2015-07-10  9:45 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-07-06  9:26 [Bug fortran/66775] New: Allocatable function result type(t) produces segfault when uninitialized vehre at gcc dot gnu.org
2015-07-09 10:37 ` [Bug fortran/66775] " vehre at gcc dot gnu.org
2015-07-09 10:38 ` vehre at gcc dot gnu.org
2015-07-10  9:45 ` vehre at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).