[Bug fortran/36771] Non-Standard addition for C_LOC and character strings
burnus at gcc dot gnu dot org
gcc-bugzilla@gcc.gnu.org
Mon Dec 15 10:50:00 GMT 2008
------- Comment #3 from burnus at gcc dot gnu dot org 2008-12-15 10:48 -------
I think the patch in comment 2 is about the wrong gfc_error.
Additionally, the generic resolution seems to be correct in gfortran (-> PR
38506).
* * *
In any case: I tried ifort, g95, NAG f95, gfortran, and sunf95 - of these only
"ifort" allows it (even with all checking enabled - thus presumably only by
accident and not on purpose).
Thus I wonder whether simply using the following "evil" workaround is better
than patching the compiler:
f_ptr = C_LOC(X(1:1))
That works with gfortran, ifort, g95 and NAG f95. (It fails with sunf95, whose
C interoperability is a bit shaky in general.) As the string should be
contiguous in memory it should be the OK. Additionally, that is also what one
would do in C:
char X[40];
ptr = &X; // or equivalently: ptr = &X[0];
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36771
More information about the Gcc-bugs
mailing list