[petsc-dev] Function pointer conversion: undefined behavior

Karl Rupp rupp at mcs.anl.gov
Fri Jan 25 10:56:35 CST 2013


Hi Jed,

 >     seem to be quite hard to fix:
>         warning: ISO C forbids conversion of function pointer
>                  to object pointer type [-pedantic]
>
>
> Yup, this problem is well-known. I've been removing them as it makes
> sense, but since we've never used an architecture where void(*)(void)
> has a different size than void*, it hasn't been urgent to eradicate
> every last instance. That said, we're nearly there with the
> PetscObjectSetFortranCallback interface I put in two weeks ago (there
> are just a few places still using the old way, then we can remove this
> code).

Ok, great, so we have a handle on this problem.


> I think there are a couple other places, maybe in the MPI stuff, where
> function pointers and data pointers are conflated, though I think they
> are also easy enough to replace.

In the nightly tests are only very few warnings of that type left. Only 
11 files affected with about ~7 warnings each on average:
   vec/pf/impls/constant/const.c
   mat/matfd/ftn-custom/zfdmatrixf.c
   mat/impls/mffd/ftn-custom/zmffdf.c
   ksp/pc/impls/tfs/comm.c
   ksp/pc/impls/tfs/xxt.c
   ksp/pc/impls/tfs/xyt.c
   ksp/ksp/interface/ftn-custom/zitfuncf.c
   snes/interface/ftn-custom/zsnesf.c
   snes/utils/dmsnes.c
   ts/interface/ftn-custom/ztsf.c
   ts/utils/dmts.c:65
Please let me know if I can be of any help.

Best regards,
Karli




More information about the petsc-dev mailing list