https://gcc.gnu.org/bugzilla/show_bug.cgi?id=120473
Bug ID: 120473
Summary: Pointers caught with pointer &var handler not
modificable
Product: gcc
Version: 15.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: jakub at gcc dot gnu.org
Target Milestone: ---
const char r[] = "hello";
const char *s[] = { &r[0], &r[3] };
const char **p = &s[0];
int
foo ()
{
try
{
throw p;
}
catch (const char **&x)
{
if (x != &s[0])
return 1;
++x;
if (x != &s[1])
return 2;
try
{
throw;
}
catch (const char **&y)
{
if (y != &s[1])
return 3;
}
}
return 0;
}
extern "C" int printf (const char *, ...);
int
main ()
{
printf ("%d\n", foo ());
}
prints 3 with gcc++ and 0 with clang++ and MSVC.
I would have thought that https://eel.is/c++draft/except#handle-16 would say
here that the changes should be done to the exception object. Is this related
to CWG388? Though in this case it is the same type case, i.e.
https://eel.is/c++draft/except#handle-3.1
rather than https://eel.is/c++draft/except#handle-3.3 or
https://eel.is/c++draft/except#handle-3.4