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

clang-format breaks hlsl syntax for infinity (+1.#INF) #130787

Open
clshortfuse opened this issue Mar 11, 2025 · 3 comments
Open

clang-format breaks hlsl syntax for infinity (+1.#INF) #130787

clshortfuse opened this issue Mar 11, 2025 · 3 comments
Labels
clang-format HLSL HLSL Language Support

Comments

@clshortfuse
Copy link

When using clang format on

float x = y * +1.#INF;

clang-format will separate it to

float x = y * +1. #INF;

This is invalid HLSL code and won't allow it to be compiled.

@llvmbot
Copy link
Member

llvmbot commented Mar 11, 2025

@llvm/issue-subscribers-clang-format

Author: Carlos Lopez (clshortfuse)

When using clang format on ```cpp float x = y * +1.#INF; ```

clang-format will separate it to

float x = y * +1. #INF;

This is invalid HLSL code and won't allow it to be compiled.

@EugeneZelenko EugeneZelenko added the HLSL HLSL Language Support label Mar 11, 2025
@clshortfuse
Copy link
Author

clshortfuse commented Mar 11, 2025

Couldn't find an official spec for the constant, but did a find reference in this proposal:

The HLSL Infinity constant syntax violates C token rules by using the # character, and is not consistent with C or C++ language styling. This causes technical challenges by using reserved preprocessor tokens, but also makes the feature foreign and less approachable in a C-like language.

https://microsoft.github.io/hlsl-specs/proposals/0003-numeric-constants.html

Not sure if there are others from testing on https://shader-playground.timjones.io/

@clshortfuse
Copy link
Author

@llvm-beanz Hi, are you aware of any other C syntax violating constants in HLSL other than 1.#INF?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clang-format HLSL HLSL Language Support
Projects
Status: No status
Development

No branches or pull requests

3 participants