Skip to content

fix(media-io): Drop the double cast in db_to_mul that -Wconversion rejects on MinGW (#516) - #2651

Merged
zackees merged 1 commit into
masterfrom
fix/516-oracle-audio-math-float-conversion
Oct 27, 2026
Merged

zackees merged 1 commit into
masterfrom
fix/516-oracle-audio-math-float-conversion

Conversation

@zackees

@zackees zackees commented Oct 27, 2026

Copy link
Copy Markdown
Member

Why

master is red (run 40523654910, Fast Gate ⚡ → rust-test), ejected by #2632, which added -Wconversion to the obs-c-oracle STRICT_FLAGS:

warning: [email protected]: libobs/media-io/audio-math.h:38:25: error:
  conversion from 'double' to 'float' may change value [-Werror=float-conversion]
warning: [email protected]:    38 |  return isfinite((double)db) ? powf(10.0f, db / 20.0f) : 0.0f;
warning: [email protected]: cc1: all warnings being treated as errors
error: failed to run custom build command for `obs-c-oracle v0.1.0`

Translation unit: rust/obs-c-oracle/oracle/audio_controls.c ← libobs/build/libobs-ported-audio-controls.pch.h ← libobs/obs-audio-controls.c.h. Command: soldr cargo test --workspace --no-run --target x86_64-pc-windows-gnu.

The site is only hit on windows-gnu: MinGW-w64's <math.h> defines

#define isfinite(x) ((fpclassify(x) & FP_NAN) == 0)
#define __mingw_choose_expr(C, E1, E2) ((C) ? E1 : E2)   /* plain ternary */

and fpclassify picks __fpclassifyf(float) from that ternary, so the argument (double)db is type-checked as a double → float argument. glibc's fpclassify and MSVC's isfinite do not take that path, which is why the host and MSVC builds stay quiet.

Fix

db is already const float, so the cast was redundant:

-	return isfinite((double)db) ? powf(10.0f, db / 20.0f) : 0.0f;
+	return isfinite(db) ? powf(10.0f, db / 20.0f) : 0.0f;

Semantically identical on every compiler: MinGW now selects __fpclassifyf, glibc and MSVC still promote to double. No behaviour change, no -Wno-*, no pragma.

RED → GREEN

Replayed with the exact cc line from the failed job's log (MinGW x86_64-w64-mingw32-gcc 15.3.0 from the soldr syslib, same -I set, same -Werror -Wall -Wextra -Wconversion …):

  • RED on origin/master's header: libobs/media-io/audio-math.h:38:25: error: conversion from 'double' to 'float' may change value [-Werror=float-conversion] — byte-for-byte the CI diagnostic.
  • GREEN with this patch: clean.

Swept the whole oracle for the same class of finding with that flag set (all 171 non-_posix / non-platform_windows TUs):

  • 167 compile clean;
  • 4 (effect_parser_lifecycle.c, image_file.c, media_remux_adapter.c, obs_nvenc_loader.c) stop on #include of build-script generated .inc files (effect-parser-lifecycle.inc, obs-graphics-adapter.inc, media-remux-ffmpeg.inc, load_cuda_lib.inc) that only exist in OUT_DIR, so the local replay cannot reach their bodies. They are not warning failures.

Also re-checked the header with host gcc 15.2 and clang under -Wconversion -Wdouble-promotion -Werror: clean.

No docs/features.md line: build-warning only, nothing user-visible.

Refs #516 (strict-warning ratchet).

…jects on MinGW (#516)

#2632 added -Wconversion to the obs-c-oracle STRICT_FLAGS. MinGW's
isfinite(x) expands to fpclassify(x), whose float arm calls
__fpclassifyf(float) from a plain ternary, so passing (double)db
type-checks as a double->float conversion and the windows-gnu cross
build of the oracle fails under -Werror:

  libobs/media-io/audio-math.h:38:25: error: conversion from 'double'
  to 'float' may change value [-Werror=float-conversion]
  rust/obs-c-oracle/oracle/audio_controls.c (via libobs-ported-audio-controls.pch.h)

db is already a const float, so the cast was redundant: isfinite(db)
selects __fpclassifyf on MinGW, keeps the double arm on glibc/MSVC,
and produces identical code on every compiler.

Every other oracle translation unit for x86_64-pc-windows-gnu is clean
under the same flag set (167/171 compile; the 4 remaining need
build-script generated .inc files that are not part of the checkout).
@zackees
zackees added this pull request to the merge queue Oct 27, 2026
Merged via the queue into master with commit 058448a Oct 27, 2026
37 checks passed
@zackees
zackees deleted the fix/516-oracle-audio-math-float-conversion branch October 27, 2026 15:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

1 participant