Once my class doesn't have destructor defined, following code gives
warning C4189: 'f' : local variable is initialized but not referenced
(f->~Fred()
isn't recognised as referencing f
)
Is this a bug, or is this standard behaviour?
struct Fred
{
int a, b;
//~Fred(){}
};
int main()
{
char memory[sizeof(Fred)];
void * place = memory;
Fred* f = new(place)Fred();
f->~Fred();
}
This code is of course meaningless (it is minimal working sample), but I get this error in real scenario when writing pool allocator and using it like
template <typename T>
void CallDestructor(T * t)
{
t->~T();
}
I use visual studio 2013 warning level 4 I tested it on some on-line compilers without warning, but I'm not sure what is their warning level