Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
28446 Discussions

compiler option: converting a warning to an error

jct_office
Beginner
450 Views
I am running Compaq Visual Fortran 6.6. I hope someone has a solution to my problem.
I want to convert an "uninitialized variable" warning message to a fatal error. (So, when I mis-spell a variable name, my program dies rather than giving me a possibly curious result).
According to my Programmers Guide documentation, I should just compile with the options /warn:uninitialize /warn:errors (or /warn:stderrors). But this does not seem to work. The compiler does change its message from "warning" to "error". However, an object file is still created. And the program runs along its merry way with the uninitialized variable having a zero value.
Does anybody have a solution?
thanks
0 Kudos
7 Replies
Lorri_M_Intel
Employee
450 Views
Please don't take this wrong, but are you sure?
I just ran a quick test using CVF V6.6, with an uninitialized variable, and /warn:errors /warn:uninit and it did NOT create an object file, and did not continue to the link step.
If you are using the command line, please delete all object files and rebuild.
If you are using the Developer Studio interface, please do a CLEAN rebuild, and see if it "successfully" fails.
thanks -
- Lorri
0 Kudos
jct_office
Beginner
450 Views
Thank-you for examining my problem.
Yes, I am (almost) positive.
(I am an experienced VMS Fortran programmer, yet I am rather new to the Visual Fortran world)
My problem exists whether I run using a command line or the Developer Studio environment.
Let me give you a step-by-step.
1) In the Developer Studio, I create a 5-line "fixed format source file" Fortran program. The program simply tries to write an uninitialized variable.
2) Under the Project Settings, I add the /warn:uninitialize and /warn:errors options.
3) Under Build, I compile my program, getting the error message, "Error ... variable ijk used before its value has been defined" ... 1 error(s), 0 warning(s).
4) Under Build, I build the executable, getting the message, ".... 0 errors(s), 0 warning(s)"
5) I then execute the program. The program runs fine; the uninitialized variable contains a zero-value.
6) I repeat the steps above except switch to Fortran-90, Under 2, I select the "treat all warnings as errors" option. The same results occur.
What am I doing wrong? or inappropriate?
What am I doing wrong.
Thanks.
0 Kudos
Steven_L_Intel1
Employee
451 Views
Coming from VMS, you are used to a separate compile and link. In CVF, the model instead is to build the project - this compiles all the sources (as needed) and then links. If you do this, then the build will stop when the compile fails.
So do a "Build..Clean" to get rid of debris, and then become accustomed to just clicking the build button in the toolbar, or selecting Build..Build example.exe (or whatever your program is called).
0 Kudos
jct_office
Beginner
451 Views
Thank-you Steve.
Skipping the Compile and going straight to Build solves the problem.
So, as a followup -- in my command line applications, I should not usetwoDF command lines; the first compiling one or several subroutines using/compile_only option, followed by a second DF line linking the just-compiled object with my static link libraries. Instead, I should have a single DF linewhich compiles thesubroutines, followed onthe same line with the /link option, followed by my libraries, followed by the /nodefaultlib option.
Right?
Jim
0 Kudos
Steven_L_Intel1
Employee
451 Views
You can have just one DF line that names the source files and the libraries. No /link needed. The DF driver will do the right thing.
Why do you want to use /nodefaultlib? That's usually a bad idea.
0 Kudos
jct_office
Beginner
451 Views
I have no idea what the /nodefaultlib option does. However, in my documentation under /[no]link, which I was initially thinking i needed to specify and name any libraries, the following line appears: " ... but the Linker option /nodefaultlib must follow the /link option: ..."
Mucho thanks for your help.
Jim
0 Kudos
Steven_L_Intel1
Employee
451 Views
Don't use /nodefaultlib. It's all very simple:
df file1.f90 file2.f90 mylib.lib
If you want to name the executable, you can use /exe:filename
0 Kudos
Reply