Issue |
152113
|
Summary |
[LLDB] Cast to pointer-to-array-of-typeof-variable doesn't work
|
Labels |
new issue
|
Assignees |
|
Reporter |
jacobef
|
`p *(typeof(*s)(*)[3])s`, where `s` is a pointer to (say) 3 elements, does not work.
**System**: M1 Macbook Air, macOS Sequoia 15.6 (24G84), see below for clang and lldb versions.
**Reproduction**:
```
$ clang --version
Apple clang version 17.0.0 (clang-1700.0.13.5)
Target: arm64-apple-darwin24.6.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
$ lldb --version
lldb-1700.0.9.502
Apple Swift version 6.1.2 (swiftlang-6.1.2.1.2 clang-1700.0.13.5)
$ cat > repro.c <<EOF
> int main(void) {
> char *s = "abc";
> }
> EOF
$ clang -g repro.c -o repro
$ lldb ./repro
(lldb) target create "./repro"
Current executable set to '/Users/friedman/Coding/Misc/repro' (arm64).
(lldb) break set -n main
Breakpoint 1: where = repro`main + 4 at repro.c:2:7, address = 0x000000010000037c
(lldb) run
Process 3984 launched: '/Users/friedman/Coding/Misc/repro' (arm64)
Process 3984 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = breakpoint 1.1
frame #0: 0x000000010000037c repro`main at repro.c:2:7
1 int main(void) {
-> 2 char *s = "abc";
3 }
Target 0: (repro) stopped.
(lldb) step
Process 3984 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = step in
frame #0: 0x0000000100000388 repro`main at repro.c:3:1
1 int main(void) {
2 char *s = "abc";
-> 3 }
Target 0: (repro) stopped.
(lldb) p *(typeof(*s)(*)[3])s
˄
╰─ error: expected _expression_
```
This also reproduces with LLDB 20.1.8, installed via Homebrew.
Notably, `p *(char(*)[3])s` works fine; this is only a problem with typeof.
`*(typeof(*s)(*)[3])s` is in fact a valid _expression_, i.e. LLDB is incorrect to reject it, because the following compiles fine in clang:
```c
int main(void) {
char *s = "abc";
*(typeof(*s)(*)[3])s;
}
```
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs