Why doesn't g++ pay attention to __attribute__((pure)) for virtual functions?
- by jchl
According to the GCC documentation, __attribute__((pure)) tells the compiler that a function has no side-effects, and so it can be subject to common subexpression elimination.
This attribute appears to work for non-virtual functions, but not for virtual functions. For example, consider the following code:
extern void f( int );
class C {
…