-
Notifications
You must be signed in to change notification settings - Fork 380
Description
Issue Description
I ran into this bug while trying to move one of our samples to modules. With Slang 2025.22.1, running path\to\slang-2025.22.1-windows-x86_64\bin\slangc.exe" -target spirv dbg1.mesh.slang -o dbg.spv on the following set of 3 files produces the following warnings:
dbg3.h.slang(4): warning 15615: Cannot insert #pragma warning here for id '41018'
#pragma warning(disable: 41018) // Disable warning 41018 : returning without initializing some variables/parameters
^~~~~
dbg3.h.slang(6): warning 15615: Cannot insert #pragma warning here for id '41018'
#pragma warning(default: 41018)
^~~~~
dbg3.h.slang(5): warning 41018: returning without initializing out parameter 'b'
if (a > 0) return true;
^~~~~~
Shortening the line that starts // load-bearing comment in dbg2.slang makes the 3rd warning disappear, but does not fix the first two. Removing function bar in dbg2.slang fixes all 3.
The files are as follows (also attached as slang-pragma.zip ):
dbg1.slang:
import "dbg2.h";
import "dbg3.h";
[numthreads(128, 1, 1)]
[outputtopology("triangle")]
[shader("mesh")]
void main(){}dbg2.h.slang:
module "dbg2.h";
// load-bearing comment load-bearing comment load-bearing comment load-bearing comment
public bool bar(float a, out float b)
{
if(a <= 0.0)
{
#pragma warning(disable: 41018) // Disable warning 41018 : returning without initializing some variables/parameters
return false;
#pragma warning(default: 41018)
}
b = a;
return true;
}dbg3.h.slang:
module "dbg3.h";
public bool foo(float a, out float b) {
#pragma warning(disable: 41018) // Disable warning 41018 : returning without initializing some variables/parameters
if (a > 0) return true;
#pragma warning(default: 41018)
b = 0;
return false;
}My initial guess for why we're getting warning 15615 is maybe in
slang/source/slang/slang-preprocessor.cpp
Line 1109 in cc00aea
| SourceLoc::RawValue maxKnownLocation = |
maxKnownLocation winds up containing the maximum line number across all modules processed up to this point rather than the current module.
Expected Behavior
The #pragma warning(disable: 41018) should be valid and disable warning 41018.
Actual Behavior
The pragma instead produces warning 15615. Depending on factors in another file, such as the length of a comment, the pragma is ignored as well and warning 41018 is emitted.
Environment
- Slang Version (release version number or commit hash): 2025.22.1. No repro on 2025.11-12-gc5295eae2 from Vulkan SDK 1.4.321.1 or Slang version 2025.13.1.
- OS: Windows 11 23H2 (Build 22631.6199)
Additional context
Thanks!