* [Bug fortran/97031] the content of a comment line breaks compilation
2020-09-12 8:20 [Bug fortran/97031] New: the content of a comment line breaks compilation jean-pierre.flament@univ-lille.fr
@ 2020-09-12 16:14 ` kargl at gcc dot gnu.org
2020-09-13 8:02 ` jean-pierre.flament@univ-lille.fr
` (5 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: kargl at gcc dot gnu.org @ 2020-09-12 16:14 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97031
kargl at gcc dot gnu.org changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |kargl at gcc dot gnu.org
--- Comment #1 from kargl at gcc dot gnu.org ---
(In reply to jean-pierre.flament from comment #0)
> Created attachment 49211 [details]
> contains fortran pgm, system and compile info and output
>
> I would like to signal to you a compilation problem that I have solved.
>
> the following comment line
>
> ! some text... DIR/*/)
>
> seems to put the compiler into trouble. (see attachment)
>
> changing the line to
>
> ! some text... DIR/d2)
>
> solves the problem
>
> The attached file contains
>
> 1) the fortran (self contained)
> The faulty line is marked ==> FAULTY LINE,
> it is followed by the line ===> LINE OK
> 2) the system name (centos 6.10) and kernel
> 3) the command to compile
> 4) the output
>
> all these parts are sepaated by ============== lines
>
> I have also tested gfortran 6.3 (from devtoolset of centos) on the same
> computer (As far as I remember the errors are different but the compilation
> fails), and gfortran 4.9.3 also on a centos machine: same as 4.4.7).
> Sorry I have not access to newer versions of gfortran
This should be closed as INVALID.
You are preprocessing your code with cpp in traditional mode,
and therefore the '/*' in your code is the start of a C comment.
This is an user error. Not a problem with gfortran.
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug fortran/97031] the content of a comment line breaks compilation
2020-09-12 8:20 [Bug fortran/97031] New: the content of a comment line breaks compilation jean-pierre.flament@univ-lille.fr
2020-09-12 16:14 ` [Bug fortran/97031] " kargl at gcc dot gnu.org
@ 2020-09-13 8:02 ` jean-pierre.flament@univ-lille.fr
2020-09-13 15:55 ` sgk at troutmask dot apl.washington.edu
` (4 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: jean-pierre.flament@univ-lille.fr @ 2020-09-13 8:02 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97031
--- Comment #2 from jean-pierre.flament@univ-lille.fr ---
Thanks,
However, if I launch "man cpp" or "man gfortran" I can't see anything in
relation with my problem and traditional.
I just noticed that cpp recognizes the extensions .fpp .F and other uppercase
extensions.
This is why I added -cpp in the gfortran command (otherwise I have a diagnostic
because of #ifdef's
I have renamed my file with the .fpp extension; with "-cpp" in the gfortran
submission I get the same errors.
If I compile the file with extension *.f or .fpp without -cpp
1) the compilation has no error
2) a #ifdef...#endif is recognized even with a .f extension, without -cpp, in
my simple example, (I should check that the directive really is taken into
account !)
3) IF I compile my full project in a makefile, the absence of "-cpp" in the
gfortran command induces
a "Illegal preprocessor directive" error in all the routines having that
#ifdef...#endif
----- Mail original -----
De: "kargl at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
À: "jean-pierre flament" <jean-pierre.flament@univ-lille.fr>
Envoyé: Samedi 12 Septembre 2020 12:14:06
Objet: [Bug fortran/97031] the content of a comment line breaks compilation
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97031
kargl at gcc dot gnu.org changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |kargl at gcc dot gnu.org
--- Comment #1 from kargl at gcc dot gnu.org ---
(In reply to jean-pierre.flament from comment #0)
> Created attachment 49211 [details]
> contains fortran pgm, system and compile info and output
>
> I would like to signal to you a compilation problem that I have solved.
>
> the following comment line
>
> ! some text... DIR/*/)
>
> seems to put the compiler into trouble. (see attachment)
>
> changing the line to
>
> ! some text... DIR/d2)
>
> solves the problem
>
> The attached file contains
>
> 1) the fortran (self contained)
> The faulty line is marked ==> FAULTY LINE,
> it is followed by the line ===> LINE OK
> 2) the system name (centos 6.10) and kernel
> 3) the command to compile
> 4) the output
>
> all these parts are sepaated by ============== lines
>
> I have also tested gfortran 6.3 (from devtoolset of centos) on the same
> computer (As far as I remember the errors are different but the compilation
> fails), and gfortran 4.9.3 also on a centos machine: same as 4.4.7).
> Sorry I have not access to newer versions of gfortran
This should be closed as INVALID.
You are preprocessing your code with cpp in traditional mode,
and therefore the '/*' in your code is the start of a C comment.
This is an user error. Not a problem with gfortran.
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug fortran/97031] the content of a comment line breaks compilation
2020-09-12 8:20 [Bug fortran/97031] New: the content of a comment line breaks compilation jean-pierre.flament@univ-lille.fr
2020-09-12 16:14 ` [Bug fortran/97031] " kargl at gcc dot gnu.org
2020-09-13 8:02 ` jean-pierre.flament@univ-lille.fr
@ 2020-09-13 15:55 ` sgk at troutmask dot apl.washington.edu
2020-09-14 7:05 ` jean-pierre.flament@univ-lille.fr
` (3 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: sgk at troutmask dot apl.washington.edu @ 2020-09-13 15:55 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97031
--- Comment #3 from Steve Kargl <sgk at troutmask dot apl.washington.edu> ---
On Sun, Sep 13, 2020 at 08:02:01AM +0000, jean-pierre.flament@univ-lille.fr
wrote:
>
> I just noticed that cpp recognizes the extensions .fpp .F and other uppercase
> extensions.
> This is why I added -cpp in the gfortran command (otherwise I have a diagnostic
> because of #ifdef's
>
> I have renamed my file with the .fpp extension; with "-cpp" in the gfortran
> submission I get the same errors.
>
> If I compile the file with extension *.f or .fpp without -cpp
>
> 1) the compilation has no error
> 2) a #ifdef...#endif is recognized even with a .f extension, without -cpp, in
> my simple example, (I should check that the directive really is taken into
> account !)
> 3) IF I compile my full project in a makefile, the absence of "-cpp" in the
> gfortran command induces
> a "Illegal preprocessor directive" error in all the routines having that
> #ifdef...#endif
>
I don't quite follow you. But, it come down to gfortran uses
the C pre-processor when asked to pre-process a file. If you
have a C language construct such as '/*' in your Fortran code
it will cause problems.
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug fortran/97031] the content of a comment line breaks compilation
2020-09-12 8:20 [Bug fortran/97031] New: the content of a comment line breaks compilation jean-pierre.flament@univ-lille.fr
` (2 preceding siblings ...)
2020-09-13 15:55 ` sgk at troutmask dot apl.washington.edu
@ 2020-09-14 7:05 ` jean-pierre.flament@univ-lille.fr
2020-09-14 8:09 ` jean-pierre.flament@univ-lille.fr
` (2 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: jean-pierre.flament@univ-lille.fr @ 2020-09-14 7:05 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97031
--- Comment #4 from jean-pierre.flament@univ-lille.fr ---
see below:
----- Mail original -----
De: "kargl at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
À: "jean-pierre flament" <jean-pierre.flament@univ-lille.fr>
Envoyé: Dimanche 13 Septembre 2020 11:55:28
Objet: [Bug fortran/97031] the content of a comment line breaks compilation
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97031
--- Comment #3 from Steve Kargl <sgk at troutmask dot apl.washington.edu> ---
On Sun, Sep 13, 2020 at 08:02:01AM +0000, jean-pierre.flament@univ-lille.fr
wrote:
>
> I just noticed that cpp recognizes the extensions .fpp .F and other uppercase
> extensions.
> This is why I added -cpp in the gfortran command (otherwise I have a diagnostic
> because of #ifdef's
>
> I have renamed my file with the .fpp extension; with "-cpp" in the gfortran
> submission I get the same errors.
>
> If I compile the file with extension *.f or .fpp without -cpp
>
> 1) the compilation has no error
> 2) a #ifdef...#endif is recognized even with a .f extension, without -cpp, in
> my simple example, (I should check that the directive really is taken into
> account !)
> 3) IF I compile my full project in a makefile, the absence of "-cpp" in the
> gfortran command induces
> a "Illegal preprocessor directive" error in all the routines having that
> #ifdef...#endif
>
I don't quite follow you. But, it come down to gfortran uses
the C pre-processor when asked to pre-process a file. If you
have a C language construct such as '/*' in your Fortran code
it will cause problems.
====> In my remarks just above 2) and 3) I just wanted to point that,
apprently, in addtion, gfortran+cpp seem to have a different behaviour when
called in a makefile or in a simple command line. I can check that more.
===> as regards the intial point: do you find it normal that, processing a
fortran file (and I imagine that CPP knows that point since it was launched
within the gfortran command) CPP does not consider fortran comment lines as
such, and ignores their content.
In addition I noticed that there is a '*/' construct farther in the file in
an other commented line (line = "... */ ...", and that thus all the stuff
inbetween was ignored, suppresing all the declarations (character and others)
ans some other statements; this explains the diagnostics of the compiler.
another questions raises: the '*/' was within " ", i.e. a character
string... a legal fortran statement.
before commenting this line I had an other message reporting an end for
file before the end of a comment (I don't remember exactly
the formulation). That's why I finally decided to create the test file
that you have, commenting all the lines with call's and the famous line =
"...." . I know understand what happened.
but once again: cpp does not seem to understand the syntax of fortran !
this is very annoying !
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug fortran/97031] the content of a comment line breaks compilation
2020-09-12 8:20 [Bug fortran/97031] New: the content of a comment line breaks compilation jean-pierre.flament@univ-lille.fr
` (3 preceding siblings ...)
2020-09-14 7:05 ` jean-pierre.flament@univ-lille.fr
@ 2020-09-14 8:09 ` jean-pierre.flament@univ-lille.fr
2020-10-05 12:28 ` dominiq at lps dot ens.fr
2021-01-25 19:11 ` tkoenig at gcc dot gnu.org
6 siblings, 0 replies; 8+ messages in thread
From: jean-pierre.flament@univ-lille.fr @ 2020-09-14 8:09 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97031
--- Comment #5 from jean-pierre.flament@univ-lille.fr ---
I am sorry to bother you once again, for the last time. I have now understood
all things that happened while compiling the very complicated (!) program
below.
========================
program tstmak
implicit none
! a comment with /*
integer :: i
!
#ifdef _MYDEBUG_
print *,' debug printing'
#endif
i = 25
print *,'normal printing: i=',i
end program tstmak
========================================
I compiled this fortran with and without -cpp, and always with -D_MYDEBUG_ in a
command like that one
gfortran -v -ffree-form -Wall -msse2 -g -fbounds-check -fbacktrace -D_MYDEBUG_
-cpp tstmak1.f -o v1
1) if -cpp is PRESENT
a) the '/*' in the comment line causes a great problem (in that case an "end
of file") and no executable is produced
b) if I change the '/*' to anything else, no message, the executable is
produced, and prints what is expected
2) if -cpp is ABSENT
a) the '/*' in the comment line has no catastrophic effect, but a WARNING
appears
"Warning: tstmak.f:6: Illegal preprocessor directive"
however the executable is produced, and prints what is expected
It is because of this warning (and not an error) that I always put "-cpp" in my
makefiles !
===> conclusion: gfortran "tolerates" and understands "#" type directives.
This is in opposition to other compilers, which also caused my trouble
Sorry for the disturbance
JP Flament
----- Mail original -----
De: "kargl at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
À: "jean-pierre flament" <jean-pierre.flament@univ-lille.fr>
Envoyé: Dimanche 13 Septembre 2020 11:55:28
Objet: [Bug fortran/97031] the content of a comment line breaks compilation
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97031
--- Comment #3 from Steve Kargl <sgk at troutmask dot apl.washington.edu> ---
On Sun, Sep 13, 2020 at 08:02:01AM +0000, jean-pierre.flament@univ-lille.fr
wrote:
>
> I just noticed that cpp recognizes the extensions .fpp .F and other uppercase
> extensions.
> This is why I added -cpp in the gfortran command (otherwise I have a diagnostic
> because of #ifdef's
>
> I have renamed my file with the .fpp extension; with "-cpp" in the gfortran
> submission I get the same errors.
>
> If I compile the file with extension *.f or .fpp without -cpp
>
> 1) the compilation has no error
> 2) a #ifdef...#endif is recognized even with a .f extension, without -cpp, in
> my simple example, (I should check that the directive really is taken into
> account !)
> 3) IF I compile my full project in a makefile, the absence of "-cpp" in the
> gfortran command induces
> a "Illegal preprocessor directive" error in all the routines having that
> #ifdef...#endif
>
I don't quite follow you. But, it come down to gfortran uses
the C pre-processor when asked to pre-process a file. If you
have a C language construct such as '/*' in your Fortran code
it will cause problems.
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug fortran/97031] the content of a comment line breaks compilation
2020-09-12 8:20 [Bug fortran/97031] New: the content of a comment line breaks compilation jean-pierre.flament@univ-lille.fr
` (4 preceding siblings ...)
2020-09-14 8:09 ` jean-pierre.flament@univ-lille.fr
@ 2020-10-05 12:28 ` dominiq at lps dot ens.fr
2021-01-25 19:11 ` tkoenig at gcc dot gnu.org
6 siblings, 0 replies; 8+ messages in thread
From: dominiq at lps dot ens.fr @ 2020-10-05 12:28 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97031
Dominique d'Humieres <dominiq at lps dot ens.fr> changed:
What |Removed |Added
----------------------------------------------------------------------------
Last reconfirmed| |2020-10-05
Status|UNCONFIRMED |WAITING
Ever confirmed|0 |1
--- Comment #6 from Dominique d'Humieres <dominiq at lps dot ens.fr> ---
> This should be closed as INVALID.
I agree!
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug fortran/97031] the content of a comment line breaks compilation
2020-09-12 8:20 [Bug fortran/97031] New: the content of a comment line breaks compilation jean-pierre.flament@univ-lille.fr
` (5 preceding siblings ...)
2020-10-05 12:28 ` dominiq at lps dot ens.fr
@ 2021-01-25 19:11 ` tkoenig at gcc dot gnu.org
6 siblings, 0 replies; 8+ messages in thread
From: tkoenig at gcc dot gnu.org @ 2021-01-25 19:11 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97031
Thomas Koenig <tkoenig at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|WAITING |RESOLVED
CC| |tkoenig at gcc dot gnu.org
Resolution|--- |INVALID
--- Comment #7 from Thomas Koenig <tkoenig at gcc dot gnu.org> ---
I think the documentation for this is adequate:
1.3 Preprocessing and conditional compilation
=============================================
Many Fortran compilers including GNU Fortran allow passing the source
code through a C preprocessor (CPP; sometimes also called the Fortran
preprocessor, FPP) to allow for conditional compilation. In the case of
GNU Fortran, this is the GNU C Preprocessor in the traditional mode.
If the C preprocessor is used, then C preprocessor rules apply.
Closing.
^ permalink raw reply [flat|nested] 8+ messages in thread