clang 23 -Wunused-but-set-global: assert-only sInitialized static in hal/Hal.cpp
Categories
(Core :: Hardware Abstraction Layer (HAL), defect)
Tracking
()
| Tracking | Status | |
|---|---|---|
| firefox157 | --- | fixed |
People
(Reporter: RyanVM, Assigned: RyanVM)
References
(Blocks 1 open bug)
Details
Attachments
(1 external file)
hal/Hal.cpp fails to build with clang 23 on build-linux64-plain-clang-trunk/opt:
/builds/worker/checkouts/gecko/hal/Hal.cpp:51:13: error: variable 'sInitialized' set but not used [-Werror,-Wunused-but-set-global]
51 | static bool sInitialized = false;
| ^
Every read of sInitialized is inside a MOZ_ASSERT (the MOZ_IMPL_HAL_OBSERVER macro, hal::Init(), and hal::Shutdown()), so with NDEBUG set the variable is written twice and never read. Debug builds are unaffected.
-Wunused-but-set-global is new in clang 23 and is reached transitively from -Wall via -Wunused -> -Wunused-but-set-variable, so it fires without bug 2060534's explicit check_and_add_warning having landed.
| Assignee | ||
Comment 1•2 months ago
|
||
Every read of sInitialized happens inside a MOZ_ASSERT, so opt builds only ever write to it. clang 23
flags that under -Wunused-but-set-global, which -Wall now enables transitively via
-Wunused-but-set-variable, busting the plain clang-trunk build.
| Assignee | ||
Updated•2 months ago
|
Comment 3•2 months ago
|
||
| bugherder | ||
Updated•2 months ago
|
Description
•