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

Force error on warning when compiling with ifx/ifort?

JaredFrazier
Beginner
579 Views

This is a remarkably trivial question, but clearly I am missing something: I just want compilation of the below FORTRAN program to fail when compiling with `ifx`/`ifort` if a warning is thrown. I have checked the documentation, but the `-warn all,errors` flag does not work as expected. What flags do I need to accomplish this?

```fortran
! @file: warning.f90
program warning_example
implicit none
integer :: x, y

x = 10
! y is declared but never used, which should trigger a warning
print *, 'Value of x:', x
end program warning_example
```

Checking the intel docs for [-warn](https://www.intel.com/content/www/us/en/docs/fortran-compiler/developer-guide-reference/2025-0/warn.html), where the syntax is described as

> Syntax Linux: -warn [keyword[, keyword...]]

I would expect

```shell
ifort warning.f90 -warn all,errors
```

to error, however only

> warning.f90(5): remark #7712: This variable has not been used. [Y]
INTEGER :: x, y
------------------^

gets output and a binary is still is produced.

Similarly, compiling with `ifx` yields the same result. `ifx` is on my local system and is version `ifx (IFX) 2025.0.4` while `ifort` is on a cluster I am using and is version `ifort (IFORT) 2021.3.0`.

Compilation fails as expected when calling something like

```
# gfortran --version --> GNU Fortran (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0
gfortran warning.f90 -Wall -Werror
```

0 Kudos
3 Replies
andrew_4619
Honored Contributor III
549 Views

/warn:errors  on windows

 

 

ifx /warn:errors /warn:unused warn.f90
Intel(R) Fortran Compiler for applications running on Intel(R) 64, Version 2025.0.0 Build 20241008
Copyright (C) 1985-2024 Intel Corporation. All rights reserved.

warn.f90(3): remark #7712: This variable has not been used.   [Y]
integer :: x, y
--------------^
Microsoft (R) Incremental Linker Version 14.30.30709.0
Copyright (C) Microsoft Corporation.  All rights reserved.

-out:warn.exe
-subsystem:console
warn.obj

 

But no error!

 

JaredFrazier
Beginner
537 Views

I am using Linux systems, I should have mentioned specifics. The cluster is RHEL 8.9. My local system is Lubuntu 22.04.5 LTS. On these systems, no error is thrown!

0 Kudos
Ron_Green
Moderator
182 Views

We had a discussion internally on this report.

 

A "remark" is NOT a warning.  "Warning" is used when the compiler believes that the programmer needs to inspect their program because a statement is suspect.  In other words, "you should look it this, it could an error or something you should fix".  In other words, a possible defect.


In contrast, a "remark" is less severe - the compiler is telling you it noticed something that is mostly harmless and can probably be ignored but still might be something you want to inspect, potentially to clean up to make your code more tidy.  warn unused as shown in this case is a perfect example - it won't hurt the code if you have unused variables, it's probably left over code that can be removed. 

warn errors is the option to turn warnings to errors, not remarks to errors.  This has been Intel Fortran behavior for many years.  Changing this could break many builds. So we will not change this behavior. 

 

But we see your point: you ask for control on Remarks.  In a release after 2025.1.1 we will add an option in the future.  IT IS NOT THERE as of 2025.1.1 or older compilers.  It is for a future release.  It will look something like this:

ifx -c -warn all -diag-error=remark warning.f90
warning.f90(3): error #7712: This variable has not been used.   [Y]
integer :: x, y
--------------^
compilation aborted for warning.f90 (code 1)

Note that you still have the use the WARN option to have the compiler call out warning and remark messages along with this new option to instruct the compiler how you wish to treat remarks.  Without the new option the old behavior is preserved and no existing build systems will break.

 

Watch the Release Notes for compiler versions newer than 2025.1.x for the final syntax. 

Reply