Fix invalid const-qualified function pointer in delayimp.cpp (breaks x86 clang-cl build) - #98
Open
TomJoey wants to merge 1 commit into
Open
Conversation
GetProcAddress returns FARPROC (a function pointer), and `auto const
*real = ...` deduces `real` as a pointer to a const-qualified function
type, which is not a meaningful/well-formed declaration. clang-cl
rejects it outright under -m32:
error: variable 'real' with type 'const auto *' has incompatible
initializer of type 'FARPROC'
This branch is guarded by `#if defined(_M_IX86) || defined(__i386__)`,
which the project's own Windows CI matrix (x64/arm64 only) never
builds, so the break went unnoticed. Every other pointer in this file
(e.g. the `LoadLibrary` results a few lines up) uses the `auto *const`
form instead — a non-reassignable pointer to non-const data — which is
almost certainly what was intended here too. Switching to that form
fixes the x86 clang-cl build without changing behavior.
Owner
|
I currently lack the energy of supporting 32-bit platforms given their increasing rarity, but I will merge this PR if the checks pass. Please note that in order for this PR to be merged you must now add your sign-off per the DCO. (I have been implementing these processes so that contributing is smoother and there is less arbitrary-ness about it.) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
GetProcAddressreturnsFARPROC(a function pointer). The lineif (auto const *real = GetProcAddress(...); real != nullptr)in the#if defined(_M_IX86) || defined(__i386__)branch ofDelayLoadFailureHookdeducesrealas a pointer to aconst-qualified function type, which isn't a meaningful
declaration.
-m32):_M_IX86/__i386__, and theproject's own
build-windows.ymlmatrix only builds x64/arm64, sothe build break was never caught by CI.
LoadLibraryresultsa few lines above,
auto *const h = ...) usesauto *const— anon-reassignable pointer to non-const data. That's almost certainly
what was intended here too;
realis never reassigned in thisscope. Switching to that form fixes the x86 clang-cl build without
changing behavior (MSVC accepted the original spelling as a
non-conforming extension).
Test plan
file with
clang-cl -m32(-DCMAKE_C_FLAGS=-m32 -DCMAKE_CXX_FLAGS="-m32 /EHsc",Ninja, Release, shared) as part of its CI. With this one-line fix
applied, that CI run compiles and links
prism.dllsuccessfully:https://github.com/TomJoey/QQMusicEasier/actions/runs/31920480814
(previous run without the fix failed with the exact error above:
https://github.com/TomJoey/QQMusicEasier/actions/runs/31920099844)
covered automatically — happy to add an x86 job if useful.