Skip to content

Conversation

@bonachea
Copy link
Member

Fix some harmless but annoying compiler warnings throughout Caffeine encountered during development.

Here I'm deliberately ignoring the warnings currently issued by the collectives unit tests, which are resolved via complete rewrite in #158

Some examples:
```
test/main.F90:91:74:

   91 |         individual_tests = [individual_tests, a00_caffeinate_caffeinate()]
      |                                                                          ^
Warning: 'MEM[(struct test_item_t[1] *)_1380][0]' may be used uninitialized [-Wmaybe-uninitialized]

Warning: Unused parameter 'initiation_success' declared at (1) [-Wunused-parameter]
test/prif_this_image_test.F90:28:58:

   28 |         image_numbers = [(merge(0, me, me/=i), i = 1, ni)]
      |                                                          ^
Warning: 'image_numbers.offset' is used uninitialized [-Wuninitialized]
test/prif_this_image_test.F90:23:48:

   23 |         integer, allocatable :: image_numbers(:)
      |                                                ^
note: 'image_numbers' declared here
```
```
././src/caffeine/prif_private_s.F90:283:47:

  283 |     integer(int_ptr_check), parameter :: unused = 0_int_ptr_check
      |                                               1
Warning: Unused parameter 'unused' declared at (1) [-Wunused-parameter]
```

Use a real (dynamic) assertion instead.
```
././src/caffeine/coarray_queries_s.F90:64:20:

   64 |       image_index = 1 + sub(1) - coarray_handle%info%lcobounds(1)
      |                    1
Warning: Possible change of value in conversion from INTEGER(8) to INTEGER(4) at (1) [-Wconversion]
././src/caffeine/coarray_queries_s.F90:71:21:

   71 |         prior_size = prior_size * (coarray_handle%info%ucobounds(dim-1) - coarray_handle%info%lcobounds(dim-1) + 1)
      |                     1
Warning: Possible change of value in conversion from INTEGER(8) to INTEGER(4) at (1) [-Wconversion]
././src/caffeine/coarray_queries_s.F90:72:22:

   72 |         image_index = image_index + (sub(dim) - coarray_handle%info%lcobounds(dim)) * prior_size
      |                      1
Warning: Possible change of value in conversion from INTEGER(8) to INTEGER(4) at (1) [-Wconversion]
```

Add explicit truncating integer conversions
@bonachea bonachea requested a review from ktras March 26, 2025 22:06
Copy link
Collaborator

@ktras ktras left a comment

Choose a reason for hiding this comment

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

LGTM

@bonachea bonachea merged commit 5cfd8bb into BerkeleyLab:main Mar 26, 2025
3 checks passed
@bonachea bonachea deleted the warning-fixes branch March 26, 2025 23:19
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