mirror of
https://github.com/isocpp/CppCoreGuidelines.git
synced 2025-12-17 12:44:42 +03:00
@@ -6765,14 +6765,14 @@ Consider:
|
|||||||
cout << pb2->id(); // "D"
|
cout << pb2->id(); // "D"
|
||||||
|
|
||||||
if (pb1->id() == pb2->id()) // *pb1 is the same type as *pb2
|
if (pb1->id() == pb2->id()) // *pb1 is the same type as *pb2
|
||||||
if (pb2 == "D") { // looks innocent
|
if (pb2->id() == "D") { // looks innocent
|
||||||
D* pd = static_cast<D*>(pb1);
|
D* pd = static_cast<D*>(pb1);
|
||||||
// ...
|
// ...
|
||||||
}
|
}
|
||||||
// ...
|
// ...
|
||||||
}
|
}
|
||||||
|
|
||||||
The result of `pb2 == "D"` is actually implementation defined.
|
The result of `pb2->id() == "D"` is actually implementation defined.
|
||||||
We added it to warn of the dangers of home-brew RTTI.
|
We added it to warn of the dangers of home-brew RTTI.
|
||||||
This code may work as expected for years, just to fail on a new machine, new compiler, or a new linker that does not unify character literals.
|
This code may work as expected for years, just to fail on a new machine, new compiler, or a new linker that does not unify character literals.
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user