You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fpm is currently making gfortran fail on warning by hardcoding -Werror. Removing -Werror from fpm.toml doesn't change this behavior (I understand specifying flags via fpm.toml may not be implemented yet.
However, in the meantime, we shouldn't use -Werror because it's making correct code to fail. For example:
[milan@gary test_project_error]$ cat src/mylib.f90
real :: a, b
a = 2.
b = 2.
print *, a == b
end
[milan@gary test_project_error]$ cat fpm.toml
name = "package-name"
version = "0.1.0"
license = "BSD3"
author = "Author name here"
maintainer = "example@example.com"
copyright = "2020 Author name here"
dependencies = []
compiler = "gfortran"
devel-options = ["-g", "-Wall", "-Wextra", "-pedantic"]
release-options = ["-O3"]
[library]
source-dirs = "src"
[milan@gary test_project_error]$ fpm build
# gfortran (for build/debug/library/mylib.o build/debug/library/mylib.mod)
src/mylib.f90:4:8:
print *, a == b
1
Error: Equality comparison for REAL(4) at (1) [-Werror=compare-reals]
f951: all warnings being treated as errors
fpm-exe: Error when running Shake build system:
at want, called at src/Build.hs:188:11 in fpm-0.1.0.0-9zFE4ut013U9YSOSmXT3I3:Build
* Depends on: build/debug/library/package-name.a
at need, called at src/Build.hs:186:13 in fpm-0.1.0.0-9zFE4ut013U9YSOSmXT3I3:Build
* Depends on: build/debug/library/mylib.o
at &%>, called at src/Build.hs:166:11 in fpm-0.1.0.0-9zFE4ut013U9YSOSmXT3I3:Build
* Depends on: build/debug/library/mylib.o build/debug/library/mylib.mod
at cmd, called at src/Build.hs:179:19 in fpm-0.1.0.0-9zFE4ut013U9YSOSmXT3I3:Build
* Raised the exception:
Development.Shake.cmd, system command failed
Command line: gfortran -c -Jbuild/debug/library -Wall -Wextra -Wimplicit-interface -Werror -fPIC -fmax-errors=1 -g -fbounds-check -fcheck-array-temporaries -fbacktrace -o build/debug/library/mylib.o src/mylib.f90
Exit code: 1
Stderr:
src/mylib.f90:4:8:
print *, a == b
1
Error: Equality comparison for REAL(4) at (1) [-Werror=compare-reals]
f951: all warnings being treated as errors
What do you think?
The text was updated successfully, but these errors were encountered:
I think Werror is not your friend and should not be used here; especially here where we cannot guarantee a specific compiler version.
Latest gfortran actually produces spurious warnings for certain derived-type allocations so Werror would completely prevent you from producing a debug build. #50
As I mentioned on the PR, I'm fine with removing the -Werror flag from the default list. But in this instance I will point out that comparison of reals really is a bad idea. Floating point math means that equality will almost surely never be true. For example, I'm pretty sure (1.0 / 3.0) == ((1.0 / 9.0) * 3.0) is false, when you really would expect it to be true.
fpm is currently making gfortran fail on warning by hardcoding
-Werror
. Removing-Werror
from fpm.toml doesn't change this behavior (I understand specifying flags via fpm.toml may not be implemented yet.However, in the meantime, we shouldn't use
-Werror
because it's making correct code to fail. For example:What do you think?
The text was updated successfully, but these errors were encountered: