Skip to content

HLSL intrinsic will match everything and anything even forward declared template functions #7971

@Przemog1

Description

@Przemog1

Description
Currently, HLSL intrinsics exist in the global namespace. When a developer defines their own functions or utilities without explicitly specifying a namespace, DXC implicitly prioritizes HLSL intrinsics. This can silently shadow user-defined symbols, and the compiler does not report namespace shadowing or ambiguous symbol resolution. This makes it harder to detect unintentional name conflicts and reduces clarity when reading or maintaining code.

HLSL intrinsics are matched even against forward-declared function templates with no body, including templates that are intentionally disabled via enable_if. Despite the template being non-viable and non-instantiable, the compiler still treats it as a valid overload candidate and then silently falls back to the intrinsic.
This violates normal C++ overload resolution rules, where a SFINAE-disabled or non-defined template should not participate in overload resolution at all. This is not just an undesired name-lookup behavior - it is a compiler bug.

Also note that flags -Wshadow and -Wconversion have no effect.

Steps to Reproduce
Threre are several issues:

Actual Behavior
The compiler calls the HLSL intrinsic (dot) instead of the user-defined function in the custom namespace, silently ignoring the intended function.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugBug, regression, crashneeds-triageAwaiting triage

    Type

    No type

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions