Skip to content

Conversation

ncelikNV
Copy link
Contributor

@ncelikNV ncelikNV commented Oct 8, 2025

Fixes 190 warnings of the following kinds, emitted when compiling with Clang 20:

  • warning: implicit conversion from 'int' to 'float' changes value from 2147483647 to 2147483648 [-Wimplicit-const-int-float-conversion]
  • warning: variable '...' set but not used [-Wunused-but-set-variable]
  • warning: first argument in call to 'memset' is a pointer to non-trivially copyable type '...' [-Wnontrivial-memcall]

Fixes 190 warnings of the following kinds, emitted when compiling with Clang 20:

- warning: implicit conversion from 'int' to 'float' changes value from 2147483647 to 2147483648 [-Wimplicit-const-int-float-conversion]
- warning: variable '...' set but not used [-Wunused-but-set-variable]
- warning: first argument in call to 'memset' is a pointer to non-trivially copyable type '...' [-Wnontrivial-memcall]
@ncelikNV ncelikNV requested a review from a team as a code owner October 8, 2025 13:23
@ncelikNV ncelikNV added the pr: non-breaking PRs without breaking changes label Oct 8, 2025
Copy link
Collaborator

@jkwak-work jkwak-work left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I left a few comments.

The PR description says something about memset.

warning: first argument in call to 'memset' is a pointer to non-trivially copyable type '...' [-Wnontrivial-memcall]

But I am not sure which lines are related to that.

auto& sb = m_builder;

if (const auto incompleteExpr = as<IncompleteExpr>(expr))
if (as<IncompleteExpr>(expr))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It may need more discussion about this.
But I treat this as a Slang coding style.

At some point, I think I made some changes to CMake to ignore this warning for Clang.
I am not sure why it didn't work for you.
If we go with fixing the source code rather than snoozing the warning, we will also need to revert my change in CMake.

I personally think that this is a kind of function parameter unused.

void myFunc(int probablyUnused)
{
 ... `probablyUnused` is not used ...
}

It sometimes helps us to find an unexpected mistake/bug.
And I see a value of having the warning enabled.

But the annoying part is that, when you are making code changes during the development, you have to keep removing them all. Or if you changed the code to use the variable, you have to bring them all again and you have to spend time coming up with a good variable name again.

Alternatively, we may snooze the warning with

(void)incompleteExpr; // We have SLANG_UNUSED macro too

It will be worth bringing up a discussion with more Slang dev members before committing this change.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At some point, I think I made some changes to CMake to ignore this warning for Clang.
I am not sure why it didn't work for you.

You excluded it from -Werror (which I guess you enabled manually in your local builds) in #7561.

USE_FEWER_WARNINGS adds -Wno-unused-but-set-variable: https://github.com/expipiplus1/slang/blob/27c171ffb1f965df575d9b7c1d7c555263a68fa2/cmake/CompilerFlags.cmake#L135

but not all Slang targets use that.

for (int i = 0; i < inputCount; i++)
{
inputBufferData.push_back((float)rand() / RAND_MAX);
inputBufferData.push_back(rand() / static_cast<float>(RAND_MAX));
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we improve this better with a more modern way like std::mt19937?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would that be accepted with the "be skeptical of 'modern C++' ideas unless they are clearly better than simpler alternatives" rule?

@ncelikNV
Copy link
Contributor Author

ncelikNV commented Oct 9, 2025

warning: first argument in call to 'memset' is a pointer to non-trivially copyable type '...' [-Wnontrivial-memcall]

But I am not sure which lines are related to that.

The lines changed in slang-ir.cpp are. I replaced calls to memset with value-initialization ({}).

@ncelikNV
Copy link
Contributor Author

ncelikNV commented Oct 9, 2025

I forgot to mention, I also got 6 -Wnontrivial-memcall warnings in ImGui and an ld warning in Lua about tmpnam being insecure, but I'm not sure we should try to silence those.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr: non-breaking PRs without breaking changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants