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

EnergyPlus Build Warnings #8312

Closed
Myoldmopar opened this issue Sep 27, 2020 · 0 comments · Fixed by #8391
Closed

EnergyPlus Build Warnings #8312

Myoldmopar opened this issue Sep 27, 2020 · 0 comments · Fixed by #8391
Assignees

Comments

@Myoldmopar
Copy link
Member

There are some build warnings showing up on a GCC 9.3.0 build (Ubuntu 20.04)

String length warning

In file included from /usr/include/string.h:495,
                 from /third_party/FMI/main.c:31:
In function ‘strncpy’,
    inlined from ‘getfmiEPlusVersion’ at /third_party/FMI/main.c:473:3:
/usr/include/x86_64-linux-gnu/bits/string_fortified.h:106:10: warning: ‘__builtin_strncpy’ specified bound depends on the length of the source argument [-Wstringop-overflow=]
  106 |   return __builtin___strncpy_chk (__dest, __src, __len, __bos (__dest));
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/third_party/FMI/main.c: In function ‘getfmiEPlusVersion’:
/third_party/FMI/main.c:473:36: note: length computed here
  473 |   strncpy(fmiVersionNumber, verID, strlen (verID)+ 1);
      |                                    ^~~~~~~~~~~~~~

The warning is about the use of strncpy. When using this function, the third argument is supposed to indicate the maximum number of characters to copy. In these usages, the warning is emitted because we are simply copying the entire string anyway -- the "maximum" length we are passing in is always the length of the string. So we should just be using strcpy or memcpy if we know the length ahead of time.

The usages are a little vague because the error message for each is like 10 lines long, and state that there is an inlined call in the calling structure to get to these warnings. Anyway, usages in develop with line numbers as of the time of writing:

  • third_party/FMI/main.c:473:36
  • third_party/FMI/main.c:983:4
  • third_party/FMI/main.c:979:4
  • third_party/FMI/main.c:974:5
  • third_party/FMI/main.c:1064:3
  • third_party/FMUParser/parser.c:252:16
@Myoldmopar Myoldmopar added this to the EnergyPlus Future milestone Sep 27, 2020
@jmarrec jmarrec self-assigned this Nov 23, 2020
mitchute added a commit that referenced this issue Dec 11, 2020
Fix #8312 - EnergyPlus Build Warnings on gcc >= 9
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.

2 participants