[Bug c++/106502] Three calls to __attribute__((const)) function
redi at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Tue Aug 2 06:41:49 GMT 2022
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106502
--- Comment #3 from Jonathan Wakely <redi at gcc dot gnu.org> ---
It doesn't happen unless the name() function is virtual. Reduced:
extern "C" int puts(const char*);
struct Cat
{
virtual const char* name();
};
__attribute__((const)) Cat& cat();
int main()
{
puts(cat().name());
}
Produces this gimple:
int main ()
{
int D.2388;
_1 = cat ();
_2 = cat ();
_3 = _2->_vptr.Cat;
_4 = *_3;
_5 = cat ();
_6 = OBJ_TYPE_REF(_4;(struct Cat)_1->0B) (_5);
puts (_6);
D.2388 = 0;
return D.2388;
}
More information about the Gcc-bugs
mailing list