Bug 67623 - interaction between cpp and Fortran
Summary: interaction between cpp and Fortran
Status: RESOLVED DUPLICATE of bug 58334
Alias: None
Product: gcc
Classification: Unclassified
Component: fortran (show other bugs)
Version: 6.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
Depends on:
Blocks: 28662
  Show dependency treegraph
Reported: 2015-09-18 11:20 UTC by Joost VandeVondele
Modified: 2021-08-27 02:15 UTC (History)
1 user (show)

See Also:
Known to work:
Known to fail:
Last reconfirmed: 2015-11-07 00:00:00


Note You need to log in before you can comment on or make changes to this bug.
Description Joost VandeVondele 2015-09-18 11:20:00 UTC
The C(++) preprocessor that is invoked on .F90 files can change Fortran strings, leading to unexpected results. While it is OK to remove things that are truly C comments (e.g. from headers included), this should not happen in Fortran strings? At least gfortran and ifort show different behavior.

> cat test.F90
#define FOO
WRITE(6,*) "&
&/* foobar */&
> gfortran test.F90 ; ./a.out
> ifort test.F90 ; ./a.out
 /* foobar */
Comment 1 Richard Biener 2015-09-18 11:24:11 UTC
I think multi-line strings like this are not well supported by C/C++.  Eventually fortran needs to tell the preprocessor it allows them.
Comment 2 Richard Biener 2015-09-18 11:28:32 UTC
int main()
  printf ("Hello\
          /* ssss */\

works as expected though:

> ./a.out 
Hello     /* ssss */      world

but then libcpp doesn't know about fortrans continuation character?  And C
does not accept a literal newline (we're escaping that).
Comment 3 Manuel López-Ibáñez 2015-09-18 12:32:54 UTC
Fortran devs need to add a Fortran mode to CPP.

Related to PR28662.

Tobias already mentioned this here: https://gcc.gnu.org/ml/gcc/2014-11/msg00357.html

See also the comments in https://gcc.gnu.org/ml/gcc/2014-12/msg00003.html and follow-ups.
Comment 4 Andrew Pinski 2021-08-27 02:15:20 UTC
Dup of bug 58334.

*** This bug has been marked as a duplicate of bug 58334 ***