Skip to content

MSVC 2022 compilation error in capsaicin_internal_negotiate.cpp with nested lambda template parameters #36

@hisham-hchowdhu

Description

@hisham-hchowdhu

Description

The latest code (commit 49304bdfd) fails to compile with MSVC 2022 due to template parameter scoping issues in nested lambda functions in src/core/src/capsaicin/capsaicin_internal_negotiate.cpp

Error Details

The compiler cannot resolve the template parameter SharedT from the outer lambda handleShared when used in constexpr contexts within nested lambdas like ypeStringMap, combineSharedsFunc, etc.\n\nKey error:\n`\nC:\Users\hisha\Documents\github.com\RadeonPro\Capsaicin\src\core\src\capsaicin\capsaicin_internal_negotiate.cpp(518,27): error C2923: 'std::is_same_v': 'SharedT' is not a valid template type argument for parameter '
The pattern if constexpr (is_same_v<SharedT, SharedTexture>) appears in nested lambdas and MSVC cannot properly capture/resolve the template parameter in these contexts.

Command-Line Reproduction

git clone https://github.com/GPUOpen-LibrariesAndSDKs/Capsaicin.git
cd Capsaicin
git checkout 49304bdfd
cmake -B build
cmake --build build --config Release

Expected Result

Build should complete successfully

Actual Result

Build fails with compilation errors:\n`\nC:\Users\hisha\Documents\github.com\RadeonPro\Capsaicin\src\core\src\capsaicin\capsaicin_internal_negotiate.cpp(518,27): error C2923: 'std::is_same_v': 'SharedT' is not a valid template type argument for parameter ''\nC:\Users\hisha\Documents\github.com\RadeonPro\Capsaicin\src\core\src\capsaicin\capsaicin_internal_negotiate.cpp(518,60): error C2059: syntax error: ')'\nC:\Users\hisha\Documents\github.com\RadeonPro\Capsaicin\src\core\src\capsaicin\capsaicin_internal_negotiate.cpp(519,13): error C2143: syntax error: missing ';' before '{'\n... (100+ errors cascade from the initial template parameter resolution failure)

Environment

OS: Windows 11\n- Compiler: MSVC 17.14.40 (.NET Framework) \n- Visual Studio: 2022 Professional\n- CMake: Used via Visual Studio's CMake integration\n- Commit: 49304bdfd ('Capsaicin: Add todo for shared texture scale.')\n- Build Configuration: Release x64\n\n## Additional Context\n\nAll third-party dependencies (gfx, ktx, rtxdi, yaml-cpp, meshoptimizer, etc.) compile successfully. Only the core Capsaicin library (capsaicin.vcxproj) fails during compilation.\n\nThe issue affects multiple nested lambdas in the
egotiateRenderTechniques() function, specifically within the handleShared lambda template where inner lambdas try to use the outer template parameter SharedT in compile-time type checking.\n\n### Affected Code Location\n\nFile: src/core/src/capsaicin/capsaicin_internal_negotiate.cpp\n\nStarting around line 500, the handleShared generic lambda template contains several nested lambdas:\n- ypeStringMap (line ~518)\n- combineSharedsFunc (line ~520)\n- �ddSharedFunc (line ~640)\n- sharedFunc (line ~660)\n\nAll of these attempt to use if constexpr (is_same_v<SharedT, SharedTexture>) or if constexpr (is_same_v<SharedT, SharedBuffer>) which MSVC cannot resolve.\n\n## Suggested Fix\n\nThe nested lambda structure may need to be refactored to avoid template parameter scoping issues with MSVC, possibly by:\n- Moving the inner lambdas outside and passing SharedT as a template parameter\n- Using a different approach that doesn't rely on nested constexpr template checks\n- Explicitly capturing template parameters in a way MSVC can resolve\n- Converting some lambdas to regular template functions outside the parent lambda

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions