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

Fix reference-cast compile error #98

Merged
merged 1 commit into from
Mar 15, 2025

Conversation

Wunkolo
Copy link
Contributor

@Wunkolo Wunkolo commented Mar 15, 2025

Fixes a compilation error on GCC due to the casting of a const-reference into a non-const-reference type:

../../include/hlsl++/dependent.h: In function ‘hlslpp::int1 hlslpp::asint(const float1&)’:
../../include/hlsl++/dependent.h:132:67: error: casting ‘const hlslpp::float1’ to ‘hlslpp::int1&’ does not use ‘hlslpp::int1::int1(const hlslpp::float1&)’ [-Werror=cast-user-defined]
  132 |         hlslpp_inline int1 asint(const float1& v) { return (int1&)v; }
      |                                                                   ^
../../include/hlsl++/dependent.h: In function ‘hlslpp::int2 hlslpp::asint(const float2&)’:
../../include/hlsl++/dependent.h:133:67: error: casting ‘const hlslpp::float2’ to ‘hlslpp::int2&’ does not use ‘hlslpp::int2::int2(const hlslpp::float2&)’ [-Werror=cast-user-defined]
  133 |         hlslpp_inline int2 asint(const float2& v) { return (int2&)v; }
      |                                                                   ^
../../include/hlsl++/dependent.h: In function ‘hlslpp::int3 hlslpp::asint(const float3&)’:
../../include/hlsl++/dependent.h:134:67: error: casting ‘const hlslpp::float3’ to ‘hlslpp::int3&’ does not use ‘hlslpp::int3::int3(const hlslpp::float3&)’ [-Werror=cast-user-defined]
  134 |         hlslpp_inline int3 asint(const float3& v) { return (int3&)v; }
      |                                                                   ^
../../include/hlsl++/dependent.h: In function ‘hlslpp::int4 hlslpp::asint(const float4&)’:
../../include/hlsl++/dependent.h:135:67: error: casting ‘const hlslpp::float4’ to ‘hlslpp::int4&’ does not use ‘hlslpp::int4::int4(const hlslpp::float4&)’ [-Werror=cast-user-defined]
  135 |         hlslpp_inline int4 asint(const float4& v) { return (int4&)v; }
...

I think this is just an MSVC-specific extension

Verified

This commit was signed with the committer’s verified signature.
Wunkolo Wunk
Fixes a compilation error on GCC due to the casting of a const-reference into a non-const-reference type:

```
../../include/hlsl++/dependent.h: In function ‘hlslpp::int1 hlslpp::asint(const float1&)’:
../../include/hlsl++/dependent.h:132:67: error: casting ‘const hlslpp::float1’ to ‘hlslpp::int1&’ does not use ‘hlslpp::int1::int1(const hlslpp::float1&)’ [-Werror=cast-user-defined]
  132 |         hlslpp_inline int1 asint(const float1& v) { return (int1&)v; }
      |                                                                   ^
../../include/hlsl++/dependent.h: In function ‘hlslpp::int2 hlslpp::asint(const float2&)’:
../../include/hlsl++/dependent.h:133:67: error: casting ‘const hlslpp::float2’ to ‘hlslpp::int2&’ does not use ‘hlslpp::int2::int2(const hlslpp::float2&)’ [-Werror=cast-user-defined]
  133 |         hlslpp_inline int2 asint(const float2& v) { return (int2&)v; }
      |                                                                   ^
../../include/hlsl++/dependent.h: In function ‘hlslpp::int3 hlslpp::asint(const float3&)’:
../../include/hlsl++/dependent.h:134:67: error: casting ‘const hlslpp::float3’ to ‘hlslpp::int3&’ does not use ‘hlslpp::int3::int3(const hlslpp::float3&)’ [-Werror=cast-user-defined]
  134 |         hlslpp_inline int3 asint(const float3& v) { return (int3&)v; }
      |                                                                   ^
../../include/hlsl++/dependent.h: In function ‘hlslpp::int4 hlslpp::asint(const float4&)’:
../../include/hlsl++/dependent.h:135:67: error: casting ‘const hlslpp::float4’ to ‘hlslpp::int4&’ does not use ‘hlslpp::int4::int4(const hlslpp::float4&)’ [-Werror=cast-user-defined]
  135 |         hlslpp_inline int4 asint(const float4& v) { return (int4&)v; }
...
```
@redorav redorav merged commit 1309f09 into redorav:master Mar 15, 2025
1 check was pending
@redorav
Copy link
Owner

redorav commented Mar 15, 2025

Sounds good, thanks for the fix!

@redorav
Copy link
Owner

redorav commented Mar 15, 2025

Agh that was an incorrect fix, let me do it properly

@Wunkolo Wunkolo deleted the reference-cast-fix branch March 15, 2025 20:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants