diff options
| author | Jakub Jelinek <jakub@redhat.com> | 2026-02-03 09:18:34 +0100 |
|---|---|---|
| committer | Jakub Jelinek <jakub@gcc.gnu.org> | 2026-02-03 09:18:34 +0100 |
| commit | 31ca0008418821367eaec1fa7750c18442d18c5e (patch) | |
| tree | 815f684b52d9e0098d5d8a669d64dd4af114dca4 /libjava/classpath/gnu/java/lang | |
| parent | bb4791c336e5f5c6be707a6219b128da0a0a184b (diff) | |
| download | gcc-31ca0008418821367eaec1fa7750c18442d18c5e.zip gcc-31ca0008418821367eaec1fa7750c18442d18c5e.tar.gz gcc-31ca0008418821367eaec1fa7750c18442d18c5e.tar.bz2 | |
c++: Don't call cpp_translate_string on NULL string [PR123918]
My P2246R1 patch caused diagnostics reported by running ubsan
instrumented compiler on cpp26/static_assert1.C - if len is 0,
we don't bother to allocate msg, so it stays NULL, and when I've added
cpp_translate_string call, that can invoke memcpy (something, NULL, 0);
in that case.
While that is no longer UB in C2Y since N3322, libsanitizer doesn't
know that yet and reports it anyway.
While we could just do
if (len)
{
...
}
else
msg = "";
there is really no point in trying to translate "" and allocate memory
for that, so the following patch instead by passes that translation for
len == 0.
2026-02-03 Jakub Jelinek <jakub@redhat.com>
PR c++/123918
* semantics.cc (cexpr_str::extract): Bypass cpp_translate_string
for len == 0.
Diffstat (limited to 'libjava/classpath/gnu/java/lang')
0 files changed, 0 insertions, 0 deletions
