Problem with check=all option.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxxxxxx |
|  LEGI                    |                                      |
|  BP 53 X                 | Tel 04 76 82 51 35                   |
|  38041 GRENOBLE CEDEX    | Fax 04 76 82 52 71                   |
===================================================================





[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux