Closed Bug 2067405 Opened 2 months ago Closed 2 months ago

clang 23 -Wunused-but-set-global: assert-only sInitialized static in hal/Hal.cpp

Categories

(Core :: Hardware Abstraction Layer (HAL), defect)

defect

Tracking

()

RESOLVED FIXED
157 Branch
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.

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.

Type: task → defect
Status: NEW → RESOLVED
Closed: 2 months ago
Resolution: --- → FIXED
Target Milestone: --- → 157 Branch
QA Whiteboard: [qa-triage-done-c158/b157]
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: