Re: Strange compiler error -- GFortran thinks I haven't declared a variable.



On 10/31/2011 08:22 AM, Louisa wrote:
Not really.
The messages produced by the compiler are nonsensical.

Indeed, they are, but they turned out to be not the compiler's fault. The text editor was showing me this:

! comment
real(wp) :: SD = ...

When in reality my file had this:

! comment real(wp) :: SD = ...


The compiler was effectively saying that SD wasn't declared, and of course it has no implicit type because my program is running under implicit none.


The OP might have obtained better feedback by using a decent compiler.

I use gfortran with "-Wall -fimplicit-none -std=2008 -fbounds-check". Is there a different compiler or flag that you think would have helped me in this case?



The compiler he used doesn't print the complete source line
in the event of an error.

Yes it did... It correctly detected that I was using a variable that was not declared (due to the buggy editor) and complained in the line where I tried to use it.


The OP might have found his error by reducing the problem
to the bare minimum, by first compiling the function by itself.

The OP tried that, but as you might imagine, every time he copied and pasted the offending function to a different file to make a test program the error went away.

I also tried retracing my steps, reviewing the changes I had done recently, trying to undo the recent changes, etc. You know, natural things you try when your program stops working.

It took a while before it occurred to me that the editor might be showing me something different from what is really in the file. The moment I tried using a different editor, the problem became clear.

Cheers,
Daniel.
.



Relevant Pages

  • Re: Command line compiler
    ... I'm vastly more productive with the Microsoft tools than with the ... EMACS is the Only Real Editor. ... I'm very serious about the usability of the Unix tools; when I had to go back and use ... The compiler, at least as of five years ago, according ...
    (microsoft.public.vc.mfc)
  • Re: AfxGetApp() returns NULL
    ... the compiler gives us the opportunity to do it our way ... ... someone else who wants 4 spaces per tab can set their own value as well. ... A decent editor handles the continuation-of-parameters so easily that it doesn't even ... The same holds true with Vista vs. XP. ...
    (microsoft.public.vc.mfc)
  • Re: Visual C++ 6 support issue
    ... Of course, Eclipse ... The parse is done by the compiler ... > Microsoft has tried to pass off as an editor) ... ...
    (microsoft.public.vc.mfc)
  • Re: MVP Award...
    ... I'm a speed demon, power programmer. ... Qedit power programmer editor ... ALWAYS invoked and this is where there are compiler delays. ... One reason VS6 was faster was that it was both incomplete and wrong. ...
    (microsoft.public.vc.mfc)
  • Re: Editors
    ... > That's a bit harsh given that one's opinion of an IDE is ... Opinions fill in where facts aren't available -- but in this case, ... The compiler IS drastically improved -- but if you look back at the ... The editor has not gained you a better compiler. ...
    (comp.lang.cpp)