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

2 compiler warnings seem to indicate errors #83

Closed
paultol opened this issue Dec 3, 2023 · 1 comment
Closed

2 compiler warnings seem to indicate errors #83

paultol opened this issue Dec 3, 2023 · 1 comment

Comments

@paultol
Copy link

paultol commented Dec 3, 2023

While compiling normApp.cpp

../src/common/normApp.cpp:617:20: warning: ‘void operator delete(void*, long unsigned int)’ called on pointer returned from a mismatched allocation function [-Wmismatched-new-delete]
  617 |             delete address;
      |                    ^~~~~~~
../src/common/normApp.cpp:607:39: note: returned from ‘void* operator new [](long unsigned int)’
  607 |         if (!(address = new char[len+1]))

and

../src/common/normPostProcess.cpp: In member function ‘void NormPostProcessor::GetCommand(char*, unsigned int)’:
../src/common/normPostProcess.cpp:51:20: warning: ‘char* strncpy(char*, const char*, size_t)’ output truncated before terminating nul copying 4 bytes from a string of the same length [-Wstringop-truncation]
   51 |             strncpy(buffer, "none", 4);
      |             ~~~~~~~^~~~~~~~~~~~~~~~~~~

both seem to indicate genuine errors.

The former should be changed to "delete[] address" (also in the lines 606 and 626 even though g++ did not notice).

About the latter, I am not sure as the enclosing function NormPostProcessor::GetCommand does not seem to be used so intentions are unclear. Unless it is there for future use, I think the safest would be to remove the function.

@bebopagogo
Copy link
Collaborator

I just pushed a commit that addresses these comments/issues. Thank you for your input!

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

No branches or pull requests

2 participants