<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/61333>61333</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
lldb 14: "p std::string("o", std::allocator<char>())" works on "-std=gnu++14", but doesn't work on "-std=gnu++20"
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
safinaskar
</td>
</tr>
</table>
<pre>
In lldb 14 `p std::string("o", std::allocator<char>())` works on `-std=gnu++14`, but doesn't work on `-std=gnu++20`.
Here is code:
```c++
#include <stdio.h>
#include <string>
int main() {
std::string a("x");
std::string b("x", std::allocator<char> ());
printf ("");
}
```
Here is output with `-std=gnu++14`:
```text
(lldb) p std::string("o", std::allocator<char>())
(std::string) $0 = "o"
```
And here is output with `-std=gnu++20`:
```text
(lldb) p std::string("o", std::allocator<char>())
error: expression failed to parse:
error: <user expression 0>:1:1: no matching constructor for initialization of 'std::string' (aka 'std::basic_string<char, std::char_traits<char>, std::allocator<char>>')
std::string("o", std::allocator<char>())
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~
note: candidate constructor not viable: no known conversion from 'const char[2]' to 'std::basic_string<char, std::char_traits<char>, std::allocator<char>>' for 1st argument
note: candidate constructor not viable: no known conversion from 'const char[2]' to 'const std::basic_string<char, std::char_traits<char>, std::allocator<char>>' for 1st argument
note: candidate constructor not viable: no known conversion from 'const char[2]' to 'std::initializer_list<char>' for 1st argument
note: candidate constructor not viable: no known conversion from 'const char[2]' to 'std::basic_string<char, std::char_traits<char>, std::allocator<char>>::__sv_wrapper' for 1st argument
note: candidate constructor not viable: requires 1 argument, but 2 were provided
note: candidate constructor not viable: requires 1 argument, but 2 were provided
note: candidate constructor not viable: requires 1 argument, but 2 were provided
note: candidate constructor not viable: requires 3 arguments, but 2 were provided
note: candidate constructor not viable: requires 3 arguments, but 2 were provided
note: candidate constructor not viable: requires 3 arguments, but 2 were provided
note: candidate constructor not viable: requires 0 arguments, but 2 were provided
note: candidate constructor not viable: requires 4 arguments, but 2 were provided
```
`p std::string("o")` doesn't work at all with both standards.
Here is full dockerfile for reproducing:
```dockerfile
# Reproducible
# 20230227 = 20230227T000000Z = 20230226T090712Z
FROM debian:sid-20230227
ENV LC_ALL C.UTF-8
# Following two lines help us achieve full reproducibility
RUN sed -i 's~^URIs:.*$~URIs: http://snapshot.notset.fr/archive/debian/20230226T090712Z~' /etc/apt/sources.list.d/debian.sources
RUN echo 'Acquire::Check-Valid-Until "false";' > /etc/apt/apt.conf.d/02acquire-check-valid-until
RUN apt-get update && apt-get install -y --no-install-recommends apt-utils whiptail
RUN apt-get update && apt-get install -y --no-install-recommends less mc aptitude man-db
RUN apt-get update && apt-get install -y --no-install-recommends clang lldb
RUN echo '#include <stdio.h>' >> a.cpp
RUN echo '#include <string>' >> a.cpp
RUN echo 'int main() {' >> a.cpp
RUN echo ' std::string a("x");' >> a.cpp
RUN echo ' std::string b("x", std::allocator<char> ());' >> a.cpp
RUN echo ' printf ("");' >> a.cpp
RUN echo '}' >> a.cpp
RUN clang++ -fno-limit-debug-info -std=gnu++14 -g -o a a.cpp
RUN lldb ./a -o 'br set --file a.cpp --source-pattern printf' -o 'r' -o 'p std::string("o", std::allocator<char>())' < /dev/null
RUN lldb ./a -o 'br set --file a.cpp --source-pattern printf' -o 'r' -o 'p std::string("o")' < /dev/null
RUN clang++ -fno-limit-debug-info -std=gnu++20 -g -o a a.cpp
RUN lldb ./a -o 'br set --file a.cpp --source-pattern printf' -o 'r' -o 'p std::string("o", std::allocator<char>())' < /dev/null
RUN lldb ./a -o 'br set --file a.cpp --source-pattern printf' -o 'r' -o 'p std::string("o")' < /dev/null
```
Here is full output: https://paste.debian.net/1273635/
Also: as you can see, I see `ModuleNotFoundError: No module named 'lldb.embedded_interpreter'` messages. I don't know whether this is related. I reported that error here: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1032423
</pre>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