https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103827
--- Comment #11 from Jan Hubicka <hubicka at gcc dot gnu.org> ---
I see, I misread Jonathan's answer. If const is relevant only on definition,
what about this one:
#include <cstdio>
struct foo
{
int a;
void bar() const;
~foo()
{
if (a != 42)
printf ("optimize me away");
}
};
__attribute__ ((noinline))
void test(const struct foo a)
{
a.bar();
}
int main()
{
test({42});
return 0;
}
Here we assume that call to bar may modify the object (since const is
irrelevant) but it is declared const inside test definition, which may be
relevant?