Skip to content

signed/unsigned overload resolution error seems unjustified #5115

Open

Description

Consider this input program:

void f(unsigned int){}
void f(int){}

float4 PSMain() : SV_TARGET
{
    f(1);
    return (float4)0;
}

There is a complaint that says:

<source>:6:5: error: call to 'f' is ambiguous
    f(1);
    ^
<source>:1:6: note: candidate function
void f(unsigned int){}
     ^
<source>:2:6: note: candidate function
void f(int){}
     ^

(godbolt permalink https://godbolt.org/z/K5rWWj4c3)

whereas the slight variation to this program:

void f(unsigned int){}
void f(int){}

float4 PSMain() : SV_TARGET
{
    f(1u);  // arg type unsigned
    return (float4)0;
}

The build now passes with no complaint.

To evaluate if that behavior is reasonable, I check against the C++ equivalent in gcc12 (godbolt default)
and get a pass build in both situation.
with an assembly that lists either call f(int) or call f(unsigned int) depending on literal suffix at call site.
(https://godbolt.org/z/h4s4bx566)
I therefore infer, that the DXC behavior is not reasonable.

Which suggests to me possibly a shortcoming somewhere around the management of the unsigned type qualifier, since I recall reporting another bug on that before.

Activity

  1. added
    bug
    and removed
    needs-triage
    on Jun 30, 2023
  2. llvm-beanz commented on Jun 30, 2023

    @llvm-beanz
    Collaborator

    This is caused by broken behavior in DXC's overload resolution. We have a bunch of related issues that will need to be addressed in order to support this planned fix for HLSL 202x.

    That feature is effectively going to result in us adopting C++ overload rules completely for HLSL, which should solve this and related issues.

  3. added
    hlsl-next
    on Jun 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bughlsl-next

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions