Skip to content

Conversation

spall
Copy link
Collaborator

@spall spall commented Sep 15, 2025

A proposal to disallow explicit conversions for inout parameters.


## Introduction

DXC allows explicitly casting an array of type T to a vector of type T as an inout parameter.
Copy link
Collaborator

Choose a reason for hiding this comment

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

I would swap the contents of the "Proposed Solution" and "Introduction" sections.

A one sentence introduction gives a good summary of the proposal, and your examples here give a more concrete understanding of the proposal and why it matters.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I sort of did that, but ended up moving the examples to motivation, but I was still more verbose in the introduction.

Co-authored-by: Damyan Pepper <damyanp@microsoft.com>
Copy link
Collaborator

@bob80905 bob80905 left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Collaborator

@bob80905 bob80905 left a comment

Choose a reason for hiding this comment

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

Talked with Sarah offline, had more time to understand the proposal better.

@@ -0,0 +1,112 @@
---
title: "NNNN - Disallow all explicit conversions in inout parameters"
Copy link
Collaborator

Choose a reason for hiding this comment

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

Consider changing the proposal to be more general, like "Disallow all explicit conversions from producing an LValue"


DXC inconsistently allows some C style explicit casts to produce LValues and be
used as arguments for inout parameters. However, C style explicit casts do not
produce LValues and inout parameters require LValues.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Consider adding that HLSL should mimic C++ behavior as closely as possible, so because C++ doesn't allow LValues as a result of these casts, HLSL shouldn't either.

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

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

4 participants