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

This commit is contained in:
Jonathan G Rennison 2019-04-24 19:06:25 +01:00
parent 1397bf5755
commit fedfedc492
2 changed files with 9 additions and 3 deletions

View File

@ -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:

View File

@ -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)