Closed
Description
To reproduce, debug the following on macOS:
#include <unordered_map>
int main() {
std::unordered_map<int, int> m;
m[1] = 2;
std::unordered_map<int, int>& ref = m;
const std::unordered_map<int, int>& const_ref = m;
return 0; // break
}
When breakpoint is reached, print ref
and const_ref
.
Expected: const_ref
is printed in the same way as ref
.
Actual: they are printed differently:
> clang++ -g main.cpp
> lldb a.out
(lldb) target create "a.out"
Current executable set to '/path/to/a.out' (arm64).
(lldb) version
lldb version 21.0.0git (git@github.com:llvm/llvm-project.git revision c3b160bcaa7dd5b5564ae8868fb33e7ba6169283)
clang revision c3b160bcaa7dd5b5564ae8868fb33e7ba6169283
llvm revision c3b160bcaa7dd5b5564ae8868fb33e7ba6169283
(lldb) b main.cpp:8
Breakpoint 1: where = a.out`main + 88 at main.cpp:8:3, address = 0x0000000100000540
(lldb) run
Process 87854 launched: '/path/to/a.out' (arm64)
Process 87854 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = breakpoint 1.1
frame #0: 0x0000000100000540 a.out`main at main.cpp:8:3
5 m[1] = 2;
6 std::unordered_map<int, int>& ref = m;
7 const std::unordered_map<int, int>& const_ref = m;
-> 8 return 0; //break
9 }
(lldb) frame var ref
(std::unordered_map<int, int> &) ref = 0x000000016fdff040 size=1: {
[0] = (first = 1, second = 2)
}
(lldb) frame var const_ref
(const std::unordered_map<int, int> &) const_ref = 0x000000016fdff040 size=1: {
[0] = {
__cc_ = (first = 1, second = 2)
}
}
(lldb)
It seems to happen because LibCxx.cpp isStdTemplate()
doesn't handle modifiers.