COMP: Use value initialization to zero-initialize thread id variable#5419
Conversation
61ae052 to
8d9bfb1
Compare
nullptr over zero for pointer initialization8d9bfb1 to
51eded9
Compare
51eded9 to
546c8fb
Compare
|
Sorry, forgot to force push yesterday. |
There was a problem hiding this comment.
Pull Request Overview
This pull request addresses a warning triggered by the use of an integer literal for initializing a thread identifier by switching to value initialization.
- Replace "pthread_t threadHandle = 0;" with "pthread_t threadHandle = {};" to zero-initialize the thread id variable and eliminate the warning.
|
IIRC I have a branch where I started on #3136 which would fix the issue in a different way. |
|
@seanm thanks for this additional information; until your fixes land in the code base, can you please try building locally with this patch set? If the warning goes away, I would prefer to have this merged to lower the noise from the dashboard. |
|
I've finally caught up on all my ITK github emails, and see only now that you changed this to not use nullptr. This new way is probably fine. IIRC this was the last -Wzero-as-null-pointer-constant in ITK! |
|
Tried locally, I see just one more (though of course I did not build every possible module or permutation): Want to amend this PR to fix that one too? |
Use value initialization to zero-initialize thread id variable.
Fixes:
```
In file included from
Core/Common/src/itkPlatformMultiThreader.cxx:35:
[CTest: warning matched]
Core/Common/src/itkPlatformMultiThreaderPosix.cxx:172:28:
warning: zero as null pointer constant [-Wzero-as-null-pointer-constant]
172 | pthread_t threadHandle = 0;
| ^
| nullptr
[CTest: warning suppressed] 1 warning generated.
```
raised for example in:
https://open.cdash.org/viewBuildError.php?type=1&buildid=10477917
and
```
ITK/Modules/Core/Common/include/itkThreadSupport.h:45:55:
warning: zero as null pointer constant [-Wzero-as-null-pointer-constant]
45 | constexpr ThreadProcessIdType ITK_DEFAULT_THREAD_ID = 0;
| ^
| nullptr
```
reported by a local build.
546c8fb to
fa1a33e
Compare
|
Re: #5419 (comment) commit amended, force pushed. Thanks for having tried this @seanm. |
I have the same recollection. I've had to back out that change in the past as well. It would be great to have the proper #ifdef initializaitons for when it is needed to be 0 and when it should be nullptr. |
|
/azp run ITK.Windows |
f20640e
into
InsightSoftwareConsortium:master
Use value initialization to zero-initialize thread id variable.
Fixes:
raised for example in:
https://open.cdash.org/viewBuildError.php?type=1&buildid=10477917
and
reported by a local build.
PR Checklist