Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Variable name is not printed on the error message when it is uninitialized #6305

Open
jkwak-work opened this issue Feb 6, 2025 · 1 comment
Assignees
Labels
goal:client support Feature or fix needed for a current slang user. GoodFirstBug Great bug for people getting going in slang codebase

Comments

@jkwak-work
Copy link
Collaborator

There is a case where the variable name is not printed with the error message.
It seems to be related to for loop and [unroll] doesn't help.

//TEST_INPUT:ubuffer(data=[2.0 1.0 5.0 2.0 1.0 -4.0 -5.0 4.0], stride=4):name=gInput
RWStructuredBuffer<float> gInput;

//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name=outputBuffer
RWStructuredBuffer<float> outputBuffer;

int test(int inVal)
{
    return inVal;
}

[Shader("compute")]
[NumThreads(4, 1, 1)]
void computeMain(int3 dispatchThreadID : SV_DispatchThreadID)
{
    int tid = dispatchThreadID.x;
    int inVal;// = tid;
    for (int i = 0; i <2; ++i)
    {
        int outVal = test(inVal);
        outputBuffer[tid] = outVal;
    }
}

The error message for the code above is following,

$ slangc.exe repro.slang
repro.slang(29): warning 41016: use of uninitialized variable ''
    int outVal = test(inVal);
                     ^

Note that if you comment out the line of for loop, the error message properly prints the variable name,

repro.slang(29): warning 41016: use of uninitialized variable 'inVal'
    int outVal = test(inVal);
                     ^

When debugged, the instance is "kIROp_Undefined" and it doesn't have any name as if it is synthesized for implicit type casting or something.

@jkwak-work jkwak-work added goal:client support Feature or fix needed for a current slang user. GoodFirstBug Great bug for people getting going in slang codebase labels Feb 6, 2025
@jkwak-work jkwak-work self-assigned this Feb 6, 2025
@csyonghe
Copy link
Collaborator

There is now a findBestSourceLocFromUses function that you can call on the undef inst to report a better location.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
goal:client support Feature or fix needed for a current slang user. GoodFirstBug Great bug for people getting going in slang codebase
Projects
None yet
Development

No branches or pull requests

2 participants