Issue |
122948
|
Summary |
clang-format doesn't handle the spaceship "<=>" symbol correctly
|
Labels |
clang-format
|
Assignees |
|
Reporter |
chriskot870
|
I was referred here to post a potential bug in the clang-format application.
I am running Ubuntu 24.04. The version of clang-format is:
```
$ clang-format --version
Ubuntu clang-format version 18.1.3 (1ubuntu1)
```
I use this file:
```
#include <stdio.h>
#include <compare>
int main() {
int x = 5;
int y = 6;
if ((x <=> y) != 0) {
printf("x is not equal too y\n");
}
}
```
I can compile and run it.
```
$ g++ -std=c++23 spaceship_test.cpp
$ ./a.out
x is not equal too y
```
I then run clang-format and try to compile:
```
$ clang-format -i spaceship_test.cpp
$ g++ -std=c++23 spaceship_test.cpp
spaceship_test.cpp: In function βint main()β:
spaceship_test.cpp:11:13: error: expected primary-_expression_ before β>β token
11 | if ((x <= > y) != 0) {
| ^
```
Indeed in the file the <=> has been changed to "<= >" Notice the space symbol after the "=".
```
#include <stdio.h>
#include <compare>
int main() {
int x = 5;
int y = 6;
if ((x <= > y) != 0) {
printf("x is not equal too y\n");
}
}
```
Here is the clang-format file I am using [clang-format.txt](https://github.com/user-attachments/files/18414723/clang-format.txt). I had to add a .txt in order for the tool to accept the .clang-format file
I assume this is some sort of bug in clang-format.
Thanks
Chris
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs