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
* [Bug fortran/29616] Run-time check using nullified pointers
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 ` 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
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: fxcoudert at gcc dot gnu dot org @ 2007-03-18 17:54 UTC (permalink / raw)
To: gcc-bugs
--
fxcoudert at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Ever Confirmed|0 |1
Keywords| |diagnostic
Last reconfirmed|0000-00-00 00:00:00 |2007-03-18 17:54:18
date| |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29616
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug fortran/29616] Run-time check using nullified pointers and deallocated variables
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 ` burnus at gcc dot gnu dot org
2007-03-22 22:33 ` burnus at gcc dot gnu dot org
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: burnus at gcc dot gnu dot org @ 2007-03-22 22:30 UTC (permalink / raw)
To: gcc-bugs
------- Comment #1 from burnus at gcc dot gnu dot org 2007-03-22 22:30 -------
Besides pointers, the same is also true for deallocated variables, only that
the unknown state does not exist. (Idea taken from 31318)
> 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.
(a) should be possible if one restricts oneself to restricts oneself to local
variables. If they are passed as actual argument to non-pointer (or
non-allocatable) dummies, this is also an error.
For allocatable variables the checking is always possible.
--
burnus at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Summary|Run-time check using |Run-time check using
|nullified pointers |nullified pointers and
| |deallocated variables
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29616
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug fortran/29616] Run-time check using nullified pointers and deallocated variables
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
4 siblings, 0 replies; 6+ messages in thread
From: burnus at gcc dot gnu dot org @ 2007-03-22 22:33 UTC (permalink / raw)
To: gcc-bugs
------- Comment #2 from burnus at gcc dot gnu dot org 2007-03-22 22:32 -------
*** Bug 31318 has been marked as a duplicate of this bug. ***
--
burnus at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |vivekrao4 at yahoo dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29616
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug fortran/29616] Run-time check using nullified pointers and deallocated variables
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
` (2 preceding siblings ...)
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
4 siblings, 0 replies; 6+ messages in thread
From: burnus at gcc dot gnu dot org @ 2009-06-29 21:00 UTC (permalink / raw)
To: gcc-bugs
------- Comment #3 from burnus at gcc dot gnu dot org 2009-06-29 21:00 -------
PR 40580 added an argument checking for pointer/proc-pointer/allocatable, i.e.
the example "call foo(r)" of comment 0 is now detected via -fcheck=pointer.
TODO:
a) call sub( uninit_alloc_returning_function() )
does not work as the _gfortran_internal_pack comes too early, see comment in
gfortran.dg/pointer_check_5.f90
b) Assignments are not checked, e.g.
r = 5.0 (see comment 0)
c) One can add checks for uninitialized pointers - by automatically
initializing them to a special value - and checking for that value.
d) There are still issues with proc-pointer returning functions; tracked at PR
40593
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29616
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug fortran/29616] Run-time check using nullified pointers and deallocated variables
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
` (3 preceding siblings ...)
2009-06-29 21:00 ` burnus at gcc dot gnu dot org
@ 2009-06-30 15:22 ` janus at gcc dot gnu dot org
4 siblings, 0 replies; 6+ messages in thread
From: janus at gcc dot gnu dot org @ 2009-06-30 15:22 UTC (permalink / raw)
To: gcc-bugs
------- Comment #4 from janus at gcc dot gnu dot org 2009-06-30 15:21 -------
PR 39230 is connected to item (c) in comment #3.
--
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).