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

Fix #8312 - EnergyPlus Build Warnings on gcc >= 9 #8391

Merged
merged 15 commits into from
Dec 11, 2020

Conversation

jmarrec
Copy link
Contributor

@jmarrec jmarrec commented Nov 24, 2020

Pull request overview

Pull Request Author

Add to this list or remove from it as applicable. This is a simple templated set of guidelines.

  • Title of PR should be user-synopsis style (clearly understandable in a standalone changelog context)
  • Label the PR with at least one of: Defect, Refactoring, NewFeature, Performance, and/or DoNoPublish
  • Pull requests that impact EnergyPlus code must also include unit tests to cover enhancement or defect repair
  • Author should provide a "walkthrough" of relevant code changes using a GitHub code review comment process
  • If any diffs are expected, author must demonstrate they are justified using plots and descriptions
  • If changes fix a defect, the fix should be demonstrated in plots and descriptions
  • If any defect files are updated to a more recent version, upload new versions here or on DevSupport
  • If IDD requires transition, transition source, rules, ExpandObjects, and IDFs must be updated, and add IDDChange label
  • If structural output changes, add to output rules file and add OutputChange label
  • If adding/removing any LaTeX docs or figures, update that document's CMakeLists file dependencies

Reviewer

This will not be exhaustively relevant to every PR.

  • Perform a Code Review on GitHub
  • If branch is behind develop, merge develop and build locally to check for side effects of the merge
  • If defect, verify by running develop branch and reproducing defect, then running PR and reproducing fix
  • If feature, test running new feature, try creative ways to break it
  • CI status: all green or justified
  • Check that performance is not impacted (CI Linux results include performance check)
  • Run Unit Test(s) locally
  • Check any new function arguments for performance impacts
  • Verify IDF naming conventions and styles, memos and notes and defaults
  • If new idf included, locally check the err file and other outputs

@jmarrec jmarrec added Defect Includes code to repair a defect in EnergyPlus DoNotPublish Includes changes that shouldn't be reported in the changelog labels Nov 24, 2020
@jmarrec jmarrec requested a review from Myoldmopar November 24, 2020 13:42
@jmarrec jmarrec self-assigned this Nov 24, 2020
Comment on lines +787 to +789
if (CMAKE_COMPILER_IS_GNUCXX AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 9.0)
target_link_libraries( energypluslib util )
endif()
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't link without this on GCC 10. Undefined reference to forkpty and openpty

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@@ -104,6 +104,7 @@ ELSEIF ( CMAKE_COMPILER_IS_GNUCXX OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang"
ADD_CXX_DEFINITIONS("-pipe") # Faster compiler processing
ADD_CXX_DEFINITIONS("-pedantic") # Turn on warnings about constructs/situations that may be non-portable or outside of the standard
ADD_CXX_DEFINITIONS("-Wall -Wextra") # Turn on warnings
ADD_CXX_DEFINITIONS("-Werror") # Treat warnings as errors
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm curious to see if clang will throw or not. We can remove this line if it's problematic, but it worked on GCC and we might as well turn it on to avoid having warnings sneak into the codebase.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

@jmarrec jmarrec Nov 24, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(Enabling /W4 or /Wall on windows would be interesting too)

STRING (REGEX REPLACE "/W3" "/W1" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") # Increase to /W2 then /W3 as more serious warnings are addressed (using regex to avoid VC override warnings)

Comment on lines +51 to +56
fmiInteger *sizefmuResFolder,
fmiReal *timeOut,
fmiInteger *visible,
fmiInteger *interactive,
fmiInteger *loggingOn,
fmiInteger *index);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Plenty of changes are due to the fact that I clang-formatted all the files in the FMI and FMUParser folders, as they were pretty messy.

/// that mapped to fmiFunctions and will be exported
/// in .dll
///////////////////////////////////////////////////////

#include "FMI/fmiModelFunctions.h"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Include problem.


// load lib by specifying path to the binaries
if (loadLib(trimfmuWorkingFolder, fmuInstances[_c->index]->modelID, fmuInstances[_c->index])) {
memcpy(fmiVersionNumber, err_msg, strlen(err_msg));
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

stringop-overflow warning. (side note: fmiVersionNumber is supposed to be allocated outside of the function, hoping that it is indeed, and correctly...)


if (fmu.modelDescription==NULL){
printfError("Fail to parse xml file \"%s\".\n", xmlPat);
free(xmlPat);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Free xmlPat, and as soon as it's not used anymore

tmp = malloc(length*sizeof(char));
strcpy(tmp, fmuFilNam);
length = strlen(fmuFilNam);
tmp = (char *)malloc((length+1) * sizeof(char));
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

malloc to length + 1

Comment on lines +94 to +96
free(tmp);
free(filNam);
free(ext);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

free eveything


objNam = (char *)calloc((length + 1), sizeof(char));
// Copy the fmufilNam without extension as objNam
if (memcpy(objNam, fmuFilNam, length) == NULL) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

stringop-overflow warning.

return -1;
}

// This is pretty useless as calloc will initialize to 0 (which is in effect the null-terminator)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

meh.

@mitchute
Copy link
Collaborator

Confirmed that this fixes build warnings with gcc >= 9. Pulling in develop one more time, then this should go right in.

@mitchute
Copy link
Collaborator

This looks good. Merging.

@mitchute mitchute merged commit 9c6810d into develop Dec 11, 2020
@mitchute mitchute deleted the 8312_build_warnings_v2 branch December 11, 2020 01:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Defect Includes code to repair a defect in EnergyPlus DoNotPublish Includes changes that shouldn't be reported in the changelog
Projects
None yet
Development

Successfully merging this pull request may close these issues.

EnergyPlus Build Warnings
7 participants