public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/29616]  New: Run-time check using nullified pointers
@ 2006-10-27 15:10 tobias dot burnus at physik dot fu-berlin dot de
  2007-03-18 17:54 ` [Bug fortran/29616] " fxcoudert at gcc dot gnu dot org
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: tobias dot burnus at physik dot fu-berlin dot de @ 2006-10-27 15:10 UTC (permalink / raw)
  To: gcc-bugs

I think there are essentially two problems possible with pointers:

(a) Uninitialized pointer (i.e. neither NULL nor associated)
(b) Using an unassociated pointer

I think checking (a) is not easily doable as one would need to pass this status
(has been initialized? yes/no) on to subroutines.
(NAG f95 does so, but one needs to compile all parts of the program with this
option as the variable status is passed on to the subroutines. This
-C=uninitialized options is still great to find uninitialized variables, esp.
those (e.g. integer) which can not be pre-autoinitialized by NaN.)


Thus this is a request for enhancement for the second type.

Example:

program pointtest
  implicit none
  real, pointer :: r
  nullify(r)
  call foo(r) ! Error one
  r = 5.0     ! Error two
contains
  subroutine foo(bar)
     real, target, intent(in) :: bar
     ! The error occures already here and not in the next line!
     print *, bar
  end subroutine foo
end program pointtest


Both are caught by NAG f95 with -C=pointer and by ifort with -check pointer:

Reference to disassociated POINTER R
and
forrtl: severe (408): fort: (7): Attempt to use pointer R when it is not
associated with a target

However, the error analysis could be improved for both:
Ifort gives a trace, but even with "-g" it does not show where.
NAG at least coredumps and thus one can find out where it crashes:
gdb -> bt
...
#3  0x00002af4962e5e1a in __NAGf90_badptr1 () from /opt/nag/lib/libf98.so.1
#4  0x0000000000403338 in main (argc=1, argv=0x7fff14a00578) at pointest.f90:6

We should try to find something, which is easily debuggable (e.g. spitting out
the file and line number?). If we say that the user should use gdb himself [as
we used to with boundary check], then we should at least tell, were to set the
break point [unless we coredump, the one can use "bt"].
At least I didn't found it obvious to set a break point at "exit__" (or
something like that), which was also in a library not loaded when loading the
program in gdb. Well, fortunally -fbounds-check now prints file and line :-)


(The two pointer tests of Polyhedron's diagnotic check, by the way, only the
first type.)


-- 
           Summary: Run-time check using nullified pointers
           Product: gcc
           Version: 4.3.0
            Status: UNCONFIRMED
          Severity: enhancement
          Priority: P3
         Component: fortran
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: tobias dot burnus at physik dot fu-berlin dot de


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


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

end of thread, other threads:[~2009-06-30 15:22 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-10-27 15:10 [Bug fortran/29616] New: Run-time check using nullified pointers tobias dot burnus at physik dot fu-berlin dot de
2007-03-18 17:54 ` [Bug fortran/29616] " fxcoudert at gcc dot gnu dot org
2007-03-22 22:30 ` [Bug fortran/29616] Run-time check using nullified pointers and deallocated variables burnus at gcc dot gnu dot org
2007-03-22 22:33 ` burnus at gcc dot gnu dot org
2009-06-29 21:00 ` burnus at gcc dot gnu dot org
2009-06-30 15:22 ` janus at gcc dot gnu dot 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).