Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Correct code fails to build due to hardcoded -Werror #56

Closed
milancurcic opened this issue Apr 26, 2020 · 3 comments · Fixed by #59
Closed

Correct code fails to build due to hardcoded -Werror #56

milancurcic opened this issue Apr 26, 2020 · 3 comments · Fixed by #59

Comments

@milancurcic
Copy link
Member

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?

@LKedward
Copy link
Member

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

@everythingfunctional
Copy link
Member

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.

@milancurcic
Copy link
Member Author

In most cases, yes, and that's why there should be a warning for it. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants