I have a C++ standard related question. Let's say I have 2 derived object D1 and D2 (which may contain class D virtual functions) of an identical class base B. Now, I create base pointers bpD1 and bpD2 to those objects.
1) Are bpD1 and bpD2 *guaranteed* to be different if the derived part of D1 and D2 are different even though the base part have identical values, OR,
2) does the c++ standard authorise a smart optimised compiler to use an identical value for bpD1 and bpD2 when it later sees in the code that the derived (different) parts are never actually used for these 2 derived object and thus they are functionnaly equal?
Where in the standard is this written to be authorised or prohibited?
The reason of the question is that I want to use those bpD1 and bpD2 to check if D1 and D2 themselves are identical by simply checking if bpD1=bpD2, and I am afraid a very optimised compiler could say that bpD1=bpD2 even though D1 is different from D2 (if the optimiser finds that the base part of D1 and D2 are equal and sees that I never later use the non-base part of D1 and D2).
Help on this matter would be greatly apreciated. Thanks in advance.