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

Ensure standard-conformance and eliminate warnings #752

Closed
rouson opened this issue Sep 13, 2022 · 9 comments
Closed

Ensure standard-conformance and eliminate warnings #752

rouson opened this issue Sep 13, 2022 · 9 comments
Labels
enhancement New feature or request

Comments

@rouson
Copy link
Contributor

rouson commented Sep 13, 2022

Description

I propose adopting the following two practices to fpm's portability and robustness:

  • Standard conformance and
  • Treat warnings as errors.

This issue was inspired by my attempt to build fpm-0.6.0.F90 with the Cray Fortran compiler version 13.0.1. The result is an internal compiler error (ICE). In my experience, the most common cause of an ICE is non-conforming code.

The Numerical Algorithms Group (NAG) Fortran Compiler is widely considered the best compiler for checking standard conformance so I then tried building with NAG's compiler using the command nagfor -fpp fpm-0.6.0.F90, where the -fpp invokes NAG's Fortran preprocessor. The result below contains a long list of warnings and compiler messages about questionable code followed by what appear to be four ICEs with NAG. As time permits, I'll investigate whether I can address these and submit related pull requests.

NAG Fortran Compiler Release 7.1(Hanzomon) Build 7113
Warning: fpm-0.6.0.F90, line 1116: C_ASSOCIATED explicitly imported into FPM_STRINGS but not used
Warning: fpm-0.6.0.F90, line 1116: C_INT explicitly imported into FPM_STRINGS but not used
Warning: fpm-0.6.0.F90, line 1116: C_NULL_CHAR explicitly imported into FPM_STRINGS but not used
Warning: fpm-0.6.0.F90, line 1116: INPUT_UNIT explicitly imported into FPM_STRINGS (as STDIN) but not used
Warning: fpm-0.6.0.F90, line 1116: OUTPUT_UNIT explicitly imported into FPM_STRINGS (as STDOUT) but not used
Questionable: fpm-0.6.0.F90, line 1186: Comment begins with the OpenMP sentinel but the -openmp option was not used
Questionable: fpm-0.6.0.F90, line 3386: Variable LENGTH set but never referenced
Warning: fpm-0.6.0.F90, line 4794: Unused dummy variable WHERE
Warning: fpm-0.6.0.F90, line 4952: REAL128 explicitly imported into PRINT_GENERIC but not used
Warning: fpm-0.6.0.F90, line 5019: REAL128 explicitly imported into PRINT_GENERIC but not used
Questionable: fpm-0.6.0.F90, line 5578: Variable IFOK set but never referenced
Warning: fpm-0.6.0.F90, line 7748: INPUT_UNIT explicitly imported into FPM_ERROR (as STDIN) but not used
Warning: fpm-0.6.0.F90, line 7748: OUTPUT_UNIT explicitly imported into FPM_ERROR (as STDOUT) but not used
Questionable: fpm-0.6.0.F90, line 8620: Variable LENGTH set but never referenced
Warning: fpm-0.6.0.F90, line 8747: FPM_STOP explicitly imported into FPM_ENVIRONMENT but not used
Warning: fpm-0.6.0.F90, line 8747: INPUT_UNIT explicitly imported into FPM_ENVIRONMENT (as STDIN) but not used
Warning: fpm-0.6.0.F90, line 8747: OUTPUT_UNIT explicitly imported into FPM_ENVIRONMENT (as STDOUT) but not used
Warning: fpm-0.6.0.F90, line 9158: SYNTAX_ERROR explicitly imported into FPM_VERSIONING but not used
Questionable: fpm-0.6.0.F90, line 9785: Variable R set but never referenced
Warning: fpm-0.6.0.F90, line 10423: C_ASSOCIATED explicitly imported into FPM_FILESYSTEM but not used
Warning: fpm-0.6.0.F90, line 10423: C_CHAR explicitly imported into FPM_FILESYSTEM but not used
Warning: fpm-0.6.0.F90, line 10423: C_F_POINTER explicitly imported into FPM_FILESYSTEM but not used
Warning: fpm-0.6.0.F90, line 10423: C_INT explicitly imported into FPM_FILESYSTEM but not used
Warning: fpm-0.6.0.F90, line 10423: C_NULL_CHAR explicitly imported into FPM_FILESYSTEM but not used
Warning: fpm-0.6.0.F90, line 10423: C_PTR explicitly imported into FPM_FILESYSTEM but not used
Warning: fpm-0.6.0.F90, line 10423: INPUT_UNIT explicitly imported into FPM_FILESYSTEM (as STDIN) but not used
Warning: fpm-0.6.0.F90, line 10423: REPLACE explicitly imported into FPM_FILESYSTEM but not used
Warning: fpm-0.6.0.F90, line 10521: TOML_DATE explicitly imported into TOMLF_UTILS but not used
Warning: fpm-0.6.0.F90, line 10521: TOML_DATETIME explicitly imported into TOMLF_UTILS but not used
Warning: fpm-0.6.0.F90, line 10521: TOML_TIME explicitly imported into TOMLF_UTILS but not used
Warning: fpm-0.6.0.F90, line 11128: Unused local variable STAT
Warning: fpm-0.6.0.F90, line 11990: Unused local variable FLAGS
Warning: fpm-0.6.0.F90, line 12662: FNV_1A explicitly imported into FPM_COMMAND_LINE but not used
Warning: fpm-0.6.0.F90, line 12662: INPUT_UNIT explicitly imported into FPM_COMMAND_LINE (as STDIN) but not used
Warning: fpm-0.6.0.F90, line 12662: LOWER explicitly imported into FPM_COMMAND_LINE but not used
Warning: fpm-0.6.0.F90, line 13212: Unused dummy variable ERROR
Warning: fpm-0.6.0.F90, line 13459: TOML_VISITOR explicitly imported into TOMLF_TYPE_KEYVAL but not used
Warning: fpm-0.6.0.F90, line 14305: TOML_VISITOR explicitly imported into TOMLF_TYPE_TABLE but not used
Warning: fpm-0.6.0.F90, line 14504: TOML_VISITOR explicitly imported into TOMLF_TYPE_ARRAY but not used
Warning: fpm-0.6.0.F90, line 15761: ADD_ARRAY explicitly imported into TOMLF_BUILD_KEYVAL but not used
Warning: fpm-0.6.0.F90, line 15761: ADD_KEYVAL explicitly imported into TOMLF_BUILD_KEYVAL but not used
Warning: fpm-0.6.0.F90, line 15761: ADD_TABLE explicitly imported into TOMLF_BUILD_KEYVAL but not used
Warning: fpm-0.6.0.F90, line 15761: LEN explicitly imported into TOMLF_BUILD_KEYVAL but not used
Warning: fpm-0.6.0.F90, line 15761: NEW_ARRAY explicitly imported into TOMLF_BUILD_KEYVAL but not used
Warning: fpm-0.6.0.F90, line 15761: NEW_KEYVAL explicitly imported into TOMLF_BUILD_KEYVAL but not used
Warning: fpm-0.6.0.F90, line 15761: NEW_TABLE explicitly imported into TOMLF_BUILD_KEYVAL but not used
Warning: fpm-0.6.0.F90, line 15761: TOML_ARRAY explicitly imported into TOMLF_BUILD_KEYVAL but not used
Warning: fpm-0.6.0.F90, line 15761: TOML_RAW_TO_TIMESTAMP explicitly imported into TOMLF_BUILD_KEYVAL but not used
Warning: fpm-0.6.0.F90, line 15761: TOML_TABLE explicitly imported into TOMLF_BUILD_KEYVAL but not used
Warning: fpm-0.6.0.F90, line 15761: TOML_VALUE explicitly imported into TOMLF_BUILD_KEYVAL but not used
Warning: fpm-0.6.0.F90, line 15878: TFC explicitly imported into TOMLF_BUILD_MERGE but not used
Warning: fpm-0.6.0.F90, line 17393: LEN explicitly imported into TOMLF_BUILD_TABLE but not used
Warning: fpm-0.6.0.F90, line 17393: NEW_ARRAY explicitly imported into TOMLF_BUILD_TABLE but not used
Warning: fpm-0.6.0.F90, line 17393: NEW_KEYVAL explicitly imported into TOMLF_BUILD_TABLE but not used
Warning: fpm-0.6.0.F90, line 17393: NEW_TABLE explicitly imported into TOMLF_BUILD_TABLE but not used
Warning: fpm-0.6.0.F90, line 17393: TFI explicitly imported into TOMLF_BUILD_TABLE but not used
Warning: fpm-0.6.0.F90, line 17393: TFR explicitly imported into TOMLF_BUILD_TABLE but not used
Warning: fpm-0.6.0.F90, line 18079: ADD_ARRAY explicitly imported into TOMLF_BUILD_ARRAY but not used
Warning: fpm-0.6.0.F90, line 18079: ADD_TABLE explicitly imported into TOMLF_BUILD_ARRAY but not used
Warning: fpm-0.6.0.F90, line 18079: NEW_ARRAY explicitly imported into TOMLF_BUILD_ARRAY but not used
Warning: fpm-0.6.0.F90, line 18079: NEW_KEYVAL explicitly imported into TOMLF_BUILD_ARRAY but not used
Warning: fpm-0.6.0.F90, line 18079: NEW_TABLE explicitly imported into TOMLF_BUILD_ARRAY but not used
Warning: fpm-0.6.0.F90, line 18079: TFI explicitly imported into TOMLF_BUILD_ARRAY but not used
Warning: fpm-0.6.0.F90, line 18079: TFR explicitly imported into TOMLF_BUILD_ARRAY but not used
Warning: fpm-0.6.0.F90, line 18079: TOML_RAW_TO_BOOL explicitly imported into TOMLF_BUILD_ARRAY but not used
Warning: fpm-0.6.0.F90, line 18079: TOML_RAW_TO_FLOAT explicitly imported into TOMLF_BUILD_ARRAY but not used
Warning: fpm-0.6.0.F90, line 18079: TOML_RAW_TO_INTEGER explicitly imported into TOMLF_BUILD_ARRAY but not used
Warning: fpm-0.6.0.F90, line 18079: TOML_RAW_TO_STRING explicitly imported into TOMLF_BUILD_ARRAY but not used
Warning: fpm-0.6.0.F90, line 18079: TOML_RAW_TO_TIMESTAMP explicitly imported into TOMLF_BUILD_ARRAY but not used
Warning: fpm-0.6.0.F90, line 18489: TOML_NEWLINE explicitly imported into TOMLF_DE but not used
Warning: fpm-0.6.0.F90, line 18800: FATAL_ERROR explicitly imported into FPM_MANIFEST_INSTALL but not used
Warning: fpm-0.6.0.F90, line 18800: TOML_STAT explicitly imported into FPM_MANIFEST_INSTALL but not used
Warning: fpm-0.6.0.F90, line 18942: TOML_STAT explicitly imported into FPM_MANIFEST_LIBRARY but not used
Warning: fpm-0.6.0.F90, line 19553: TOML_STAT explicitly imported into FPM_MANIFEST_EXECUTABLE but not used
Warning: fpm-0.6.0.F90, line 19731: DEPENDENCY_CONFIG_T explicitly imported into FPM_MANIFEST_EXAMPLE but not used
Warning: fpm-0.6.0.F90, line 19731: TOML_STAT explicitly imported into FPM_MANIFEST_EXAMPLE but not used
Warning: fpm-0.6.0.F90, line 19909: DEPENDENCY_CONFIG_T explicitly imported into FPM_MANIFEST_TEST but not used
Warning: fpm-0.6.0.F90, line 19909: TOML_STAT explicitly imported into FPM_MANIFEST_TEST but not used
Warning: fpm-0.6.0.F90, line 20555: BUILD_CONFIG_T explicitly imported into FPM_MANIFEST but not used
Warning: fpm-0.6.0.F90, line 20555: FILE_NOT_FOUND_ERROR explicitly imported into FPM_MANIFEST but not used
Warning: fpm-0.6.0.F90, line 21260: FILEWRITE explicitly imported into FPM_CMD_NEW but not used
Warning: fpm-0.6.0.F90, line 21260: OS_LINUX explicitly imported into FPM_CMD_NEW but not used
Warning: fpm-0.6.0.F90, line 21260: OS_MACOS explicitly imported into FPM_CMD_NEW but not used
Warning: fpm-0.6.0.F90, line 21260: OS_WINDOWS explicitly imported into FPM_CMD_NEW but not used
Warning: fpm-0.6.0.F90, line 21593: Unused dummy variable ROOT
Warning: fpm-0.6.0.F90, line 21636: Unused dummy variable ERROR
Warning: fpm-0.6.0.F90, line 22074: STRING_T explicitly imported into FPM_DEPENDENCY but not used
Warning: fpm-0.6.0.F90, line 23133: Unused local variable POST
Warning: fpm-0.6.0.F90, line 23135: FATAL_ERROR explicitly imported into FPM_SOURCE_PARSING but not used
Warning: fpm-0.6.0.F90, line 23135: FPM_SCOPE_APP explicitly imported into FPM_SOURCE_PARSING but not used
Warning: fpm-0.6.0.F90, line 23135: FPM_SCOPE_DEP explicitly imported into FPM_SOURCE_PARSING but not used
Warning: fpm-0.6.0.F90, line 23135: FPM_SCOPE_LIB explicitly imported into FPM_SOURCE_PARSING but not used
Warning: fpm-0.6.0.F90, line 23135: FPM_SCOPE_TEST explicitly imported into FPM_SOURCE_PARSING but not used
Warning: fpm-0.6.0.F90, line 23135: FPM_SCOPE_UNKNOWN explicitly imported into FPM_SOURCE_PARSING but not used
Warning: fpm-0.6.0.F90, line 23135: STRING_CAT explicitly imported into FPM_SOURCE_PARSING but not used
Extension(NAG): fpm-0.6.0.F90, line 23589: Line longer than 132 characters
Warning: fpm-0.6.0.F90, line 24236: OUTPUT_UNIT explicitly imported into FPM_BACKEND_OUTPUT (as STDOUT) but not used
Warning: fpm-0.6.0.F90, line 24837: INPUT_UNIT explicitly imported into FPM_BACKEND (as STDIN) but not used
Warning: fpm-0.6.0.F90, line 24837: JOIN_PATH explicitly imported into FPM_BACKEND but not used
Warning: fpm-0.6.0.F90, line 24837: OUTPUT_UNIT explicitly imported into FPM_BACKEND (as STDOUT) but not used
Warning: fpm-0.6.0.F90, line 24837: RUN explicitly imported into FPM_BACKEND but not used
Warning: fpm-0.6.0.F90, line 25386: C_ASSOCIATED explicitly imported into FPM but not used
Warning: fpm-0.6.0.F90, line 25386: C_CHAR explicitly imported into FPM but not used
Warning: fpm-0.6.0.F90, line 25386: C_F_POINTER explicitly imported into FPM but not used
Warning: fpm-0.6.0.F90, line 25386: C_INT explicitly imported into FPM but not used
Warning: fpm-0.6.0.F90, line 25386: C_NULL_CHAR explicitly imported into FPM but not used
Warning: fpm-0.6.0.F90, line 25386: C_PTR explicitly imported into FPM but not used
Warning: fpm-0.6.0.F90, line 25386: FATAL_ERROR explicitly imported into FPM but not used
Warning: fpm-0.6.0.F90, line 25386: FNV_1A explicitly imported into FPM but not used
Warning: fpm-0.6.0.F90, line 25386: FPM_INSTALL_SETTINGS explicitly imported into FPM but not used
Warning: fpm-0.6.0.F90, line 25386: FPM_NEW_SETTINGS explicitly imported into FPM but not used
Warning: fpm-0.6.0.F90, line 25386: FPM_SCOPE_DEP explicitly imported into FPM but not used
Warning: fpm-0.6.0.F90, line 25386: FPM_SCOPE_UNKNOWN explicitly imported into FPM but not used
Warning: fpm-0.6.0.F90, line 25386: FPM_TARGET_ARCHIVE explicitly imported into FPM but not used
Warning: fpm-0.6.0.F90, line 25386: FPM_TEST_SETTINGS explicitly imported into FPM but not used
Warning: fpm-0.6.0.F90, line 25386: GET_ENV explicitly imported into FPM but not used
Warning: fpm-0.6.0.F90, line 25386: MKDIR explicitly imported into FPM but not used
Warning: fpm-0.6.0.F90, line 25386: NUMBER_OF_ROWS explicitly imported into FPM but not used
Warning: fpm-0.6.0.F90, line 25386: RESOLVE_MODULE_DEPENDENCIES explicitly imported into FPM but not used
Warning: fpm-0.6.0.F90, line 25386: RESOLVE_TARGET_LINKING explicitly imported into FPM but not used
Warning: fpm-0.6.0.F90, line 25468: Unused local variable DIR
Warning: fpm-0.6.0.F90, line 25468: Unused local variable LIB
Warning: fpm-0.6.0.F90, line 25496: Unused local variable LIB
Warning: fpm-0.6.0.F90, line 25496: Unused dummy variable MODEL
Warning: fpm-0.6.0.F90, line 25496: Unused dummy variable PACKAGE
Warning: fpm-0.6.0.F90, line 25548: JOIN_PATH explicitly imported into FPM_CMD_INSTALL but not used
Warning: fpm-0.6.0.F90, line 25548: LIST_FILES explicitly imported into FPM_CMD_INSTALL but not used
Warning: fpm-0.6.0.F90, line 25548: RESIZE explicitly imported into FPM_CMD_INSTALL but not used
Questionable: fpm-0.6.0.F90, line 4423: Intrinsic function CMPLX with double precision argument and no KIND= argument returns single precision result
Extension(F2018): fpm-0.6.0.F90, line 7745: Stop-code is not constant
Questionable: fpm-0.6.0.F90, line 16477: Last statement of DO loop body is an unconditional EXIT statement
Questionable: fpm-0.6.0.F90, line 16526: Last statement of DO loop body is an unconditional EXIT statement
Questionable: fpm-0.6.0.F90, line 18196: Last statement of DO loop body is an unconditional RETURN statement
Questionable: fpm-0.6.0.F90, line 18362: Last statement of DO loop body is an unconditional EXIT statement
Questionable: fpm-0.6.0.F90, line 18764: CONTINUE statement with no label inside DO loop - did you mean CYCLE?
Questionable: fpm-0.6.0.F90, line 18897: CONTINUE statement with no label inside DO loop - did you mean CYCLE?
Questionable: fpm-0.6.0.F90, line 19062: CONTINUE statement with no label inside DO loop - did you mean CYCLE?
Questionable: fpm-0.6.0.F90, line 19489: CONTINUE statement with no label inside DO loop - did you mean CYCLE?
Questionable: fpm-0.6.0.F90, line 19667: CONTINUE statement with no label inside DO loop - did you mean CYCLE?
Questionable: fpm-0.6.0.F90, line 19845: CONTINUE statement with no label inside DO loop - did you mean CYCLE?
Questionable: fpm-0.6.0.F90, line 20217: CONTINUE statement with no label inside DO loop - did you mean CYCLE?
[NAG Fortran Compiler normal termination, 141 warnings]
fpm-0.6.0.F90:11842:39: error: member reference type 'struct fpm_command_line_DT_fpm_build_settings' is not a pointer; did you mean to use '.'?
install_settings_->fpm_build_settings_->fpm_cmd_settings_.working_dir_.addr = (Char *)0;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~
                                      .
fpm-0.6.0.F90:11842:77: error: expression is not assignable
install_settings_->fpm_build_settings_->fpm_cmd_settings_.working_dir_.addr = (Char *)0;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^
fpm-0.6.0.F90:11842:39: error: member reference type 'struct fpm_command_line_DT_fpm_build_settings' is not a pointer; did you mean to use '.'?
install_settings_->fpm_build_settings_->fpm_cmd_settings_.verbose_ = 1;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~
                                      .
fpm-0.6.0.F90:11842:68: error: expression is not assignable
install_settings_->fpm_build_settings_->fpm_cmd_settings_.verbose_ = 1;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^
4 errors generated.

Possible Solution

  1. Eliminate warnings.
  2. Report ICEs to compiler vendors.
  3. Ensure standard conformance.

Additional Information

No response

@rouson rouson added the enhancement New feature or request label Sep 13, 2022
@LKedward
Copy link
Member

Thanks Damian @rouson - yes I completely agree that we should be standard conforming in fpm and I believe this is already something that has been unofficially enforced in PR reviews. I cannot (off the top of my head) think of any areas where we are not standard conforming. I can spot two extensions mentioned in your excerpt for line length and non-constant error stop code, are there any others that you've encountered?

I notice you're compiling the single-source version here - have you tried compiling with fpm build --compiler nagfor? This would help a lot to locate the source of the ICE to a single source file.

Regarding warnings-as-errors, I'm hesitant to enforce this for developers based on the argument in this article, however it is something we could perhaps incorporate into our CI. The harder problem is the person-hours required to tackling the large number of warnings that already exist across the code-base and in our dependencies. I'm also unsure of how to deal with the well-known spurious gfortran warnings for allocation-on-assignment.

Unfortunately, I don't have access to nagfor so I'm unable to pursue some of this myself.

@awvwgk
Copy link
Member

awvwgk commented Sep 14, 2022

Maybe a bit more insightful building bb44917 with nagfor 7.1 and fpm 0.6.0:

❯ fpm build --compiler nagfor --verbose
 <INFO> BUILD_NAME: build/nagfor
 <INFO> COMPILER:  nagfor
 <INFO> C COMPILER:  nagfor
 <INFO> COMPILER OPTIONS:   -g -O0 -C=all -gline -coarray=single -PIC
 <INFO> C COMPILER OPTIONS:  
 <INFO> LINKER OPTIONS:  
 <INFO> INCLUDE DIRECTORIES:  []
 + mkdir -p build/nagfor_87A051641395E663
 + mkdir -p build/nagfor_00000000811C9DC5
 [   0%]        filesystem_utilities.c
 + mkdir -p build/nagfor_00000000811C9DC5/fpm/
 + nagfor -c ./src/filesystem_utilities.c  -o build/nagfor_00000000811C9DC5/fpm/src_filesystem_utilities.c.o
NAG Fortran Compiler Release 7.1(Hanzomon) Build 7111
 [   1%]        filesystem_utilities.c  done.
 [   1%]       fpm_backend_console.f90
 + mkdir -p build/nagfor_87A051641395E663/fpm/
 + nagfor -c ./src/fpm_backend_console.f90  -g -O0 -C=all -gline -coarray=single -PIC -mdir build/nagfor_87A051641395E663 -Ibuild/nagfor_87A051641395E663 -o build/nagfor_87A051641395E663/fpm/src_fpm_backend_console.f90.o
NAG Fortran Compiler Release 7.1(Hanzomon) Build 7111
Questionable: ./src/fpm_backend_console.f90, line 70: Comment begins with the OpenMP sentinel but the -openmp option was not used
[NAG Fortran Compiler normal termination, 1 warning]
 [   3%]       fpm_backend_console.f90  done.
 [   3%]               fpm_strings.f90
 + nagfor -c ./src/fpm_strings.f90  -g -O0 -C=all -gline -coarray=single -PIC -mdir build/nagfor_87A051641395E663 -Ibuild/nagfor_87A051641395E663 -o build/nagfor_87A051641395E663/fpm/src_fpm_strings.f90.o
NAG Fortran Compiler Release 7.1(Hanzomon) Build 7111
Warning: ./src/fpm_strings.f90, line 1115: C_ASSOCIATED explicitly imported into FPM_STRINGS but not used
Warning: ./src/fpm_strings.f90, line 1115: C_INT explicitly imported into FPM_STRINGS but not used
Warning: ./src/fpm_strings.f90, line 1115: C_NULL_CHAR explicitly imported into FPM_STRINGS but not used
Warning: ./src/fpm_strings.f90, line 1115: INPUT_UNIT explicitly imported into FPM_STRINGS (as STDIN) but not used
Warning: ./src/fpm_strings.f90, line 1115: OUTPUT_UNIT explicitly imported into FPM_STRINGS (as STDOUT) but not used
[NAG Fortran Compiler normal termination, 5 warnings]
 [   4%]               fpm_strings.f90  done.
 [   4%]                      isatty.c
 + nagfor -c ./src/ptycheck/isatty.c  -o build/nagfor_00000000811C9DC5/fpm/src_ptycheck_isatty.c.o
NAG Fortran Compiler Release 7.1(Hanzomon) Build 7111
 [   6%]                      isatty.c  done.
 [   6%]                    iscygpty.c
 + nagfor -c ./src/ptycheck/iscygpty.c  -o build/nagfor_00000000811C9DC5/fpm/src_ptycheck_iscygpty.c.o
NAG Fortran Compiler Release 7.1(Hanzomon) Build 7111
 [   7%]                    iscygpty.c  done.
 [   7%]                 constants.f90
 + nagfor -c build/dependencies/toml-f/src/tomlf/constants.f90  -g -O0 -C=all -gline -coarray=single -PIC -mdir build/nagfor_87A051641395E663 -Ibuild/nagfor_87A051641395E663 -o build/nagfor_87A051641395E663/fpm/build_dependencies_toml-f_src_tomlf_constants.f90.o
NAG Fortran Compiler Release 7.1(Hanzomon) Build 7111
[NAG Fortran Compiler normal termination]
 [   9%]                 constants.f90  done.
 [   9%]                   version.f90
 + nagfor -c build/dependencies/toml-f/src/tomlf/version.f90  -g -O0 -C=all -gline -coarray=single -PIC -mdir build/nagfor_87A051641395E663 -Ibuild/nagfor_87A051641395E663 -o build/nagfor_87A051641395E663/fpm/build_dependencies_toml-f_src_tomlf_version.f90.o
NAG Fortran Compiler Release 7.1(Hanzomon) Build 7111
[NAG Fortran Compiler normal termination]
 [  10%]                   version.f90  done.
 [  10%]                    M_CLI2.f90
 + nagfor -c build/dependencies/M_CLI2/src/M_CLI2.f90  -g -O0 -C=all -gline -coarray=single -PIC -mdir build/nagfor_87A051641395E663 -Ibuild/nagfor_87A051641395E663 -o build/nagfor_87A051641395E663/fpm/build_dependencies_M_CLI2_src_M_CLI2.f90.o
NAG Fortran Compiler Release 7.1(Hanzomon) Build 7111
Questionable: build/dependencies/M_CLI2/src/M_CLI2.f90, line 1938: Variable LENGTH set but never referenced
Warning: build/dependencies/M_CLI2/src/M_CLI2.f90, line 3344: Unused dummy variable WHERE
Warning: build/dependencies/M_CLI2/src/M_CLI2.f90, line 3502: REAL128 explicitly imported into PRINT_GENERIC but not used
Warning: build/dependencies/M_CLI2/src/M_CLI2.f90, line 3569: REAL128 explicitly imported into PRINT_GENERIC but not used
Questionable: build/dependencies/M_CLI2/src/M_CLI2.f90, line 4128: Variable IFOK set but never referenced
Questionable: build/dependencies/M_CLI2/src/M_CLI2.f90, line 2973: Intrinsic function CMPLX with double precision argument and no KIND= argument returns single precision result
[NAG Fortran Compiler normal termination, 6 warnings]
 [  12%]                    M_CLI2.f90  done.
 [  12%]                     error.f90
 + nagfor -c ./src/fpm/error.f90  -g -O0 -C=all -gline -coarray=single -PIC -mdir build/nagfor_87A051641395E663 -Ibuild/nagfor_87A051641395E663 -o build/nagfor_87A051641395E663/fpm/src_fpm_error.f90.o
NAG Fortran Compiler Release 7.1(Hanzomon) Build 7111
Warning: ./src/fpm/error.f90, line 179: INPUT_UNIT explicitly imported into FPM_ERROR (as STDIN) but not used
Warning: ./src/fpm/error.f90, line 179: OUTPUT_UNIT explicitly imported into FPM_ERROR (as STDOUT) but not used
Extension(F2018): ./src/fpm/error.f90, line 176: Stop-code is not constant
[NAG Fortran Compiler normal termination, 3 warnings]
 [  13%]                     error.f90  done.
 [  13%]                  datetime.f90
 + nagfor -c build/dependencies/toml-f/src/tomlf/datetime.f90  -g -O0 -C=all -gline -coarray=single -PIC -mdir build/nagfor_87A051641395E663 -Ibuild/nagfor_87A051641395E663 -o build/nagfor_87A051641395E663/fpm/build_dependencies_toml-f_src_tomlf_datetime.f90.o
NAG Fortran Compiler Release 7.1(Hanzomon) Build 7111
[NAG Fortran Compiler normal termination]
 [  15%]                  datetime.f90  done.
 [  15%]                     error.f90
 + nagfor -c build/dependencies/toml-f/src/tomlf/error.f90  -g -O0 -C=all -gline -coarray=single -PIC -mdir build/nagfor_87A051641395E663 -Ibuild/nagfor_87A051641395E663 -o build/nagfor_87A051641395E663/fpm/build_dependencies_toml-f_src_tomlf_error.f90.o
NAG Fortran Compiler Release 7.1(Hanzomon) Build 7111
[NAG Fortran Compiler normal termination]
 [  16%]                     error.f90  done.
 [  16%]                    verify.f90
 + nagfor -c build/dependencies/toml-f/src/tomlf/utils/verify.f90  -g -O0 -C=all -gline -coarray=single -PIC -mdir build/nagfor_87A051641395E663 -Ibuild/nagfor_87A051641395E663 -o build/nagfor_87A051641395E663/fpm/build_dependencies_toml-f_src_tomlf_utils_verify.f90.o
NAG Fortran Compiler Release 7.1(Hanzomon) Build 7111
[NAG Fortran Compiler normal termination]
 [  18%]                    verify.f90  done.
 [  18%]                    fpm_os.F90
 + nagfor -c ./src/fpm_os.F90  -g -O0 -C=all -gline -coarray=single -PIC -mdir build/nagfor_87A051641395E663 -Ibuild/nagfor_87A051641395E663 -o build/nagfor_87A051641395E663/fpm/src_fpm_os.F90.o
NAG Fortran Compiler Release 7.1(Hanzomon) Build 7111
[NAG Fortran Compiler normal termination]
 [  19%]                    fpm_os.F90  done.
 [  19%]           fpm_environment.f90
 + nagfor -c ./src/fpm_environment.f90  -g -O0 -C=all -gline -coarray=single -PIC -mdir build/nagfor_87A051641395E663 -Ibuild/nagfor_87A051641395E663 -o build/nagfor_87A051641395E663/fpm/src_fpm_environment.f90.o
NAG Fortran Compiler Release 7.1(Hanzomon) Build 7111
Questionable: ./src/fpm_environment.f90, line 194: Variable LENGTH set but never referenced
Warning: ./src/fpm_environment.f90, line 321: FPM_STOP explicitly imported into FPM_ENVIRONMENT but not used
Warning: ./src/fpm_environment.f90, line 321: INPUT_UNIT explicitly imported into FPM_ENVIRONMENT (as STDIN) but not used
Warning: ./src/fpm_environment.f90, line 321: OUTPUT_UNIT explicitly imported into FPM_ENVIRONMENT (as STDOUT) but not used
[NAG Fortran Compiler normal termination, 4 warnings]
 [  21%]           fpm_environment.f90  done.
 [  21%]                versioning.f90
 + nagfor -c ./src/fpm/versioning.f90  -g -O0 -C=all -gline -coarray=single -PIC -mdir build/nagfor_87A051641395E663 -Ibuild/nagfor_87A051641395E663 -o build/nagfor_87A051641395E663/fpm/src_fpm_versioning.f90.o
NAG Fortran Compiler Release 7.1(Hanzomon) Build 7111
Warning: ./src/fpm/versioning.f90, line 411: SYNTAX_ERROR explicitly imported into FPM_VERSIONING but not used
[NAG Fortran Compiler normal termination, 1 warning]
 [  22%]                versioning.f90  done.
 [  22%]                   convert.f90
 + nagfor -c build/dependencies/toml-f/src/tomlf/utils/convert.f90  -g -O0 -C=all -gline -coarray=single -PIC -mdir build/nagfor_87A051641395E663 -Ibuild/nagfor_87A051641395E663 -o build/nagfor_87A051641395E663/fpm/build_dependencies_toml-f_src_tomlf_utils_convert.f90.o
NAG Fortran Compiler Release 7.1(Hanzomon) Build 7111
[NAG Fortran Compiler normal termination]
 [  24%]                   convert.f90  done.
 [  24%]            fpm_filesystem.F90
 + nagfor -c ./src/fpm_filesystem.F90  -g -O0 -C=all -gline -coarray=single -PIC -mdir build/nagfor_87A051641395E663 -Ibuild/nagfor_87A051641395E663 -o build/nagfor_87A051641395E663/fpm/src_fpm_filesystem.F90.o
NAG Fortran Compiler Release 7.1(Hanzomon) Build 7111
Questionable: ./src/fpm_filesystem.F90, line 273: Comment begins with the OpenMP sentinel but the -openmp option was not used
Warning: ./src/fpm_filesystem.F90, line 487: Unused local variable FORTRAN_NAME
Warning: ./src/fpm_filesystem.F90, line 966: C_F_POINTER explicitly imported into FPM_FILESYSTEM but not used
Warning: ./src/fpm_filesystem.F90, line 966: INPUT_UNIT explicitly imported into FPM_FILESYSTEM (as STDIN) but not used
Warning: ./src/fpm_filesystem.F90, line 966: REPLACE explicitly imported into FPM_FILESYSTEM but not used
[NAG Fortran Compiler normal termination, 5 warnings]
 [  25%]            fpm_filesystem.F90  done.
 [  25%]                     utils.f90
 + nagfor -c build/dependencies/toml-f/src/tomlf/utils.f90  -g -O0 -C=all -gline -coarray=single -PIC -mdir build/nagfor_87A051641395E663 -Ibuild/nagfor_87A051641395E663 -o build/nagfor_87A051641395E663/fpm/build_dependencies_toml-f_src_tomlf_utils.f90.o
NAG Fortran Compiler Release 7.1(Hanzomon) Build 7111
Warning: build/dependencies/toml-f/src/tomlf/utils.f90, line 98: TOML_DATE explicitly imported into TOMLF_UTILS but not used
Warning: build/dependencies/toml-f/src/tomlf/utils.f90, line 98: TOML_DATETIME explicitly imported into TOMLF_UTILS but not used
Warning: build/dependencies/toml-f/src/tomlf/utils.f90, line 98: TOML_TIME explicitly imported into TOMLF_UTILS but not used
[NAG Fortran Compiler normal termination, 3 warnings]
 [  27%]                     utils.f90  done.
 [  27%]          fpm_command_line.f90
 + nagfor -c ./src/fpm_command_line.f90  -g -O0 -C=all -gline -coarray=single -PIC -mdir build/nagfor_87A051641395E663 -Ibuild/nagfor_87A051641395E663 -o build/nagfor_87A051641395E663/fpm/src_fpm_command_line.f90.o
NAG Fortran Compiler Release 7.1(Hanzomon) Build 7111
Warning: ./src/fpm_command_line.f90, line 640: Unused local variable FLAGS
Warning: ./src/fpm_command_line.f90, line 1312: INPUT_UNIT explicitly imported into FPM_COMMAND_LINE (as STDIN) but not used
Warning: ./src/fpm_command_line.f90, line 1312: LOWER explicitly imported into FPM_COMMAND_LINE but not used
[NAG Fortran Compiler normal termination, 3 warnings]
./src/fpm_command_line.f90: In function ‘fpm_command_line_MP_get_command_line_settings’:
./src/fpm_command_line.f90:487:39: error: invalid type argument of ‘->’ (have ‘struct fpm_command_line_DT_fpm_build_settings’)
             install_settings = fpm_install_settings(&
                                       ^~
./src/fpm_command_line.f90:487:39: error: invalid type argument of ‘->’ (have ‘struct fpm_command_line_DT_fpm_build_settings’)
             install_settings = fpm_install_settings(&
                                       ^~
 [  28%]          fpm_command_line.f90  done.

NAG Fortran Compiler Release 7.1(Hanzomon) Build 7111
Warning: ./src/fpm_command_line.f90, line 640: Unused local variable FLAGS
Warning: ./src/fpm_command_line.f90, line 1312: INPUT_UNIT explicitly imported into FPM_COMMAND_LINE (as STDIN) but not used
Warning: ./src/fpm_command_line.f90, line 1312: LOWER explicitly imported into FPM_COMMAND_LINE but not used
[NAG Fortran Compiler normal termination, 3 warnings]
./src/fpm_command_line.f90: In function ‘fpm_command_line_MP_get_command_line_settings’:
./src/fpm_command_line.f90:487:39: error: invalid type argument of ‘->’ (have ‘struct fpm_command_line_DT_fpm_build_settings’)
             install_settings = fpm_install_settings(&
                                       ^~
./src/fpm_command_line.f90:487:39: error: invalid type argument of ‘->’ (have ‘struct fpm_command_line_DT_fpm_build_settings’)
             install_settings = fpm_install_settings(&
                                       ^~
<ERROR> Compilation failed for object " src_fpm_command_line.f90.o "
<ERROR>stopping due to failed compilation

The error in the end is a compiler bug in nagfor 7.1, which should be reported to the NAG support.

@awvwgk
Copy link
Member

awvwgk commented Sep 14, 2022

This issue was inspired by my attempt to build fpm-0.6.0.F90 with the Cray Fortran compiler version 13.0.1. The result is an internal compiler error (ICE). In my experience, the most common cause of an ICE is non-conforming code.

An internal compiler error is strictly a bug in the compiler, please report this to the Cray support. Given that Cray Fortran requires access to a Cray machine, there is nothing we can do to work around this bug in the compiler, unless you contribute a patch with such a workaround.

Standard conformance

It's a nice idea but flawed in practice because most available implementation are imperfect to some degree. In case of a specific issue, this should be raised with the respective project and fixed if there is an actual standard violation present. If not this can be brought up with the compiler developers / support or worked around in the respective project.

Treat warnings as errors.

I don't think this is a good idea, there are false positive warnings in many compilers, treating them as errors just puts an additional burden and unreasonable demand on the project maintainers (for fpm and its dependencies).

@rouson
Copy link
Contributor Author

rouson commented Sep 15, 2022

An internal compiler error is strictly a bug in the compiler, please report this to the Cray support.

Agreed. The first person to point this issue out to me was Cray support engineer who noted several indications of likely non-conformance based on the warning messages so Cray is aware of this. As I mentioned, I will investigate this further myself and submit pull requests.

I have submitted several hundred compiler bugs on more than 6 compilers over more than 20 years. At the peak, I was submitting more than 50 bug reports annually. The most common cause of ICEs that I've observed were non-conforming code: the developer(s) wrote code in a manner that the compiler developers hadn't anticipated. The NAG compiler is developed by the Editor of the Fortran standard and was the first compiler to reach Fortran 90 compliance. The Cray compiler was the first to reach Fortran 2018 compliance. These are high-quality compilers. Causing an ICE in both should be a cause for concern.

Standard conformance

It's a nice idea but flawed in practice because most available implementation are imperfect to some degree.

Treat warnings as errors.

I don't think this is a good idea, there are false positive warnings in many compilers, treating them as errors just puts an additional burden and unreasonable demand on the project maintainers (for fpm and its dependencies).

This is a reasonably common practice -- nowhere near universal but not especially unusual. Ignoring 1, 2, or 10 warnings ultimately leads to ignoring 1,000 and eventually problems arise whether one recognizes that the problems were warned about or not. It's a sign of code smell. At a minimum, it would be far better to address the warnings on a case-by-case basis rather than to state a blanket opposition to addressing them. I will go through them in more detail and submit related pull requests. I've already observed some warnings that could be eliminated easily by deleting code the that is almost certainly pointless and must have been written by someone who didn't understand the language well.

@rouson
Copy link
Contributor Author

rouson commented Sep 15, 2022

@LKedward thanks for your thoughtful response and especially for the link to such a great article -- one worth everyone reading. The caveats the author lists at the start of the article are important -- especially the first caveat: the author enforces a zero-warning policy on their projects. The issue about a zero-warning policy introducing a toolchain dependency is especially apropos in light of the spurious gfortran warnings that you aptly cite. In fact, I fear that gfortran is doing the world a disservice by making us all comfortable with a slew of warnings because at least in the case of gfortran, it's clear that a zero-warning policy would likely be an onerous burden. Any such policy would probably have to be enforced by testing with a different compiler and I understand that might not be feasible at the present time. I have been involved in funding gfortran development for more than a decade so I don't say any of this as a criticism of gfortran, which is developed primarily by volunteers and we should all be thankful for the exceptional public service they have provided. The warnings situation with gfortran, however, further strengthens the argument for always being able to build with multiple compilers. I've worked on a lot of projects in my 43 years of writing Fortran, and I can tell you that a project's longevity will ultimately be in danger if it only compiles with one or a very small number of compilers. Just think about the cycle of life: nothing last forever. There are at least two other open-source Fortran compilers now and several commercial compilers that are based on the open-source front- or back-ends in LLVM. It might not always be the case that gfortran is near the leading edge of feature support so limiting the viable compilers to one will likely severely limit the viable language features as the language evolves.

@awvwgk
Copy link
Member

awvwgk commented Sep 15, 2022

Tried to implement this in CI for TOML Fortran (toml-f/toml-f#112), the majority of issues were false positives due to automatic LHS reallocation, which are now worked around with a dummy allocation.

@rouson
Copy link
Contributor Author

rouson commented Sep 25, 2022

I think issue #754 effectively supersedes this issue so I'm closing this one.

@rouson rouson closed this as completed Sep 25, 2022
@awvwgk
Copy link
Member

awvwgk commented Sep 26, 2022

What about the Cray failure?

@rouson
Copy link
Contributor Author

rouson commented Oct 3, 2022

@awvwgk I might come back to the Cray issue, but

  1. I'll do so in a new, more specific issue (this was overly broad and amorphous) and
  2. I'll first submit a new issue related to getting issue of getting a GCC-built fpm to work when invoked directed to use the Cray compiler. That seems like a higher priority and I'm about to submit that issue now.

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

No branches or pull requests

3 participants