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 compiler warnings with ENABLE_WARNINGS=ON #562

Merged
merged 1 commit into from
Jun 27, 2024

Conversation

masterleinad
Copy link
Contributor

Description

Fixes the warnings I am seeing with ENABLE_WARNINGS=ON on ALCF's sunspot testbed.

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature/architecture support (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Build/CI update

How Has This Been Tested?

Compiling and testing on ALCF's sunspot testbed.

Checklist:

  • I have run ./scripts/check-code-format.sh and confirm my code code follows the style guidelines of variorum
  • I have added comments in my code
  • My changes generate no new warnings (build with -DENABLE_WARNINGS=ON)
  • New and existing unit tests pass with my changes

Thank you for taking the time to contribute to Variorum!

@tpatki
Copy link
Member

tpatki commented Jun 27, 2024

Hi @masterleinad! Thank you so much for testing on sunspot for us! This is very helpful.

Could you tell me what the warning with the tid part was? I am assuming the ret warning was around uninitialized variables. It'll be good to document the warnings you were seeing in the PR, so we know what was fixed if we ever needed to revisit it.

@masterleinad
Copy link
Contributor Author

Could you tell me what the warning with the tid part was? I am assuming the ret warning was around uninitialized variables. It'll be good to document the warnings you were seeing in the PR, so we know what was fixed if we ever needed to revisit it.

/home/darndt/variorum/src/examples/openmp-examples/variorum-print-verbose-power-openmp-example.c:61:13: error: variable 'ret' is used uninitialized whenever 'if' condition is false [-Werror,-Wsometimes-uninitialized]
   61 |         if (tid == 0)
      |             ^~~~~~~~
/home/darndt/variorum/src/examples/openmp-examples/variorum-print-verbose-power-openmp-example.c:82:12: note: uninitialized use occurs here
   82 |     return ret;
      |            ^~~
/home/darndt/variorum/src/examples/openmp-examples/variorum-print-verbose-power-openmp-example.c:61:9: note: remove the 'if' if its condition is always true
   61 |         if (tid == 0)
      |         ^~~~~~~~~~~~~
   62 |         {
/home/darndt/variorum/src/examples/openmp-examples/variorum-print-verbose-power-openmp-example.c:29:12: note: initialize the variable 'ret' to silence this warning
   29 |     int ret;
      |            ^
      |             = 0

I guess the tid part is not really necessary but it's not used outside the OpenMP parallel region.

@tpatki
Copy link
Member

tpatki commented Jun 27, 2024

Thanks for documenting the errors. Merging.

@tpatki tpatki merged commit ad9091f into LLNL:dev Jun 27, 2024
9 checks passed
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 this pull request may close these issues.

2 participants