Issue |
136174
|
Summary |
cassert in comparable with c++23 multiple dimensional subscript operator
|
Labels |
new issue
|
Assignees |
|
Reporter |
cianciosa
|
The following C++23 code fails to compile
```
#include <cassert>
struct foo {
int operator[](int i, int j) {return 0;}
};
int main(int argc, const char * argv[]) {
foo f;
assert(f[0, 0] && "");
}
```
With the error
```
<source>:9:17: error: too many arguments provided to function-like macro invocation
9 | assert(f[0, 0] && "");
| ^
/usr/include/assert.h:92:11: note: macro 'assert' defined here
92 | # define assert(expr) \
| ^
<source>:9:5: error: use of undeclared identifier 'assert'; did you mean '__assert'?
9 | assert(f[0, 0] && "");
| ^~~~~~
| __assert
/usr/include/assert.h:81:13: note: '__assert' declared here
81 | extern void __assert (const char *__assertion, const char *__file, int __line)
| ^
<source>:9:5: warning: _expression_ result unused [-Wunused-value]
9 | assert(f[0, 0] && "");
| ^~~~~~
```
It appears the preprocessor does't understand the new C++ index syntax. This was
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs