Silence false-positive misalignment UBSan warning in YAPF road, ship

pull/88/head
Jonathan G Rennison 5 years ago
parent 1397bf5755
commit fedfedc492

@ -28,7 +28,9 @@ protected:
/** to access inherited path finder */
inline Tpf& Yapf()
{
return *static_cast<Tpf *>(this);
/* use two lines to avoid false-positive Undefined Behavior Sanitizer warnings when alignof(Tpf) > alignof(*this) and *this does not meet alignof(Tpf) */
Tpf *p = static_cast<Tpf *>(this);
return *p;
}
public:
@ -72,7 +74,9 @@ protected:
/** to access inherited path finder */
inline Tpf& Yapf()
{
return *static_cast<Tpf *>(this);
/* use two lines to avoid false-positive Undefined Behavior Sanitizer warnings when alignof(Tpf) > alignof(*this) and *this does not meet alignof(Tpf) */
Tpf *p = static_cast<Tpf *>(this);
return *p;
}
public:

@ -42,7 +42,9 @@ protected:
/** to access inherited path finder */
Tpf& Yapf()
{
return *static_cast<Tpf *>(this);
/* use two lines to avoid false-positive Undefined Behavior Sanitizer warnings when alignof(Tpf) > alignof(*this) and *this does not meet alignof(Tpf) */
Tpf *p = static_cast<Tpf *>(this);
return *p;
}
int SlopeCost(TileIndex tile, TileIndex next_tile, Trackdir trackdir)

Loading…
Cancel
Save