* Problem with check=all option.
@ 2014-02-05 10:13 Patrick Begou
0 siblings, 0 replies; only message in thread
From: Patrick Begou @ 2014-02-05 10:13 UTC (permalink / raw)
To: gcc-help
Hi,
for several days I'm having some difficulties with the "-check=all" option with
gcc 4.8.1 I've found a lot of discussions on the web but I'm unable to solve the
problem.
I have isolated the problem I need to solve in a small example:
A C function wich reflect my library. It receives a pointer to an array of int.
If this pointer is set to NULL the informations in the array are not used in
nthe C function, else the provided values are used (in my test I just print 2
values).
I'm calling this function from a fortran application. I've build an interface in
the fortran program for the C function. All works fine but if I set the
"check=all" flags I have an error because my fortran pointer is not allocated!
As I need to debug a larger application I need to check pointers. Any suggestion ?
Thanks
Patrick
C function ======================
#include <stdio.h>
#include <stdlib.h>
void isnull(int* ptr, int* n)
{
if (ptr == NULL)
printf("Ok il est null\n");
else
printf("pas null: %d to %d\n",ptr[0], ptr[*n-1]);
}
Fortran main ===============
PROGRAM nulod
use iso_c_binding
IMPLICIT NONE
INTERFACE
SUBROUTINE isnull (arg,n) bind(c)
use iso_c_binding
IMPLICIT NONE
INTEGER(c_int) ::n
INTEGER(c_int),DIMENSION(n)::arg
END SUBROUTINE isnull
END INTERFACE
INTEGER, DIMENSION(:), POINTER:: var =>NULL()
INTEGER, DIMENSION(4), TARGET :: valeur=(/1,2,3,4/)
CALL isnull(var,4)
var=>valeur
CALL isnull(var,4)
END PROGRAM nulod
--
===================================================================
| Equipe M.O.S.T. | |
| Patrick BEGOU | mailto:Patrick.Begou@grenoble-inp.fr |
| LEGI | |
| BP 53 X | Tel 04 76 82 51 35 |
| 38041 GRENOBLE CEDEX | Fax 04 76 82 52 71 |
===================================================================
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2014-02-05 10:13 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-02-05 10:13 Problem with check=all option Patrick Begou
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).