This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug fortran/32223] Backslash handling inconsistent



------- Comment #2 from dfranke at gcc dot gnu dot org  2007-06-05 17:38 -------
Some more information:

"Change the interpretation of backslashes in string literals from
“C-style” escape characters to a single backslash character. "

$> cat char.f90
character(len=1) :: c
DATA c / '\0' /
print *, c
end

$> gfortran-svn -fbackslash char.f90 && ./a.out
char.f90:2.9:

DATA c / '\0' /
        1
Warning: initialization string truncated to match variable at (1)
 \

$> gfortran-svn -fno-backslash char.f90 && ./a.out
char.f90:2.9:

DATA c / '\0' /
        1
Warning: initialization string truncated to match variable at (1)
 \


The same is true for assignments, but here, -Wall is needed to print a warning
message:

$> cat char.f90
character(len=1) :: c
c = '\0'
print *, c
end

$> gfortran-svn -fno-backslash char.f90 && ./a.out
 \
$> gfortran-svn -fbackslash char.f90 && ./a.out
 \
gfortran-svn -fbackslash -Wall char.f90 && ./a.out
char.f90:2.8:

c = '\0'
       1
Warning: CHARACTER expression will be truncated in assignment (1/2) at (1)

For the latter example the dump shows:
  __builtin_memmove (&c, "\\0", 1);
regardless of -f[no-]backslash.


-- 

dfranke at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |dfranke at gcc dot gnu dot
                   |                            |org


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=32223


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]