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

Missing warning for implicit cast to signed int from literal > max int #4683

Closed
tex3d opened this issue Sep 22, 2022 · 1 comment
Closed
Labels
bug Bug, regression, crash

Comments

@tex3d
Copy link
Contributor

tex3d commented Sep 22, 2022

Generally, implicit casts from literal values that don't fit into the range of a target type will produce a warning and tell you the different value that will actually be used (based on truncation, etc...).

Here's an example:

// warning: implicit conversion from 'literal int' to 'int' changes value from -3000000000 to 1294967296
int val = -3000000000;

However, if the value is larger than the maximum positive value for a signed int, but fits into the equivalent bit-sized unsigned value limit, no such warning is emitted:

// no warning, because it fits into unsigned limit for same bit-sized int
int val = 3000000000;

I think we should emit a warning for this case.

@damyanp
Copy link
Member

damyanp commented Aug 14, 2024

This is resolved in HLSL202x.

@damyanp damyanp closed this as not planned Won't fix, can't repro, duplicate, stale Aug 14, 2024
@github-project-automation github-project-automation bot moved this to Triaged in HLSL Triage Aug 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Bug, regression, crash
Projects
Archived in project
Development

No branches or pull requests

2 participants