https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89924
--- Comment #5 from Eyal Rozenberg <eyalroz at technion dot ac.il> --- (In reply to Jan Hubicka from comment #3) > The reason why we do not devirtualize is that only information about Aint is > the type of function parameter "Only"? :-) > and we do not believe it implies the type of > memory location it points to because there is no read or anything from that > pointer before it is casted to struct A* and pointer of a given type does > not need to necessarily point to memory location of the same type unless you > dereference it. > > Is it really valid to devirtualize here? IANALL, but yes. You're using terms like "belief" and talk about speculative inference based on partial evidence. Why? foo_virtual gets a pointer to an Aint. Why should the compiler needs to second-guess this?