# Accesses the sanitizer build (OPENCMR2_SANITIZE) does not report.
#
# Each of these functions reads a dword where the original reads a byte,
# short or byte array and keeps only the low byte or bytes it needs, as the
# original's code does: the read runs one to three bytes past the variable,
# into the same stack frame or the padding after it, and the value used is
# the same. The original's machine code loads the dword (mov eax, [x]; and
# eax, 0xff); a byte read compiles to other instructions (xor eax, eax;
# mov al, [x]), so the decompilation keeps the dword. Any other access in
# them is still checked by UBSan.
#
# The UBSan sections below list indexing and alignment the original does
# itself; the function type check is off for the whole build (CMakeLists.txt).

[address]
# *(int *)(light + n) & 0xff over BYTE light[4]
fun:*StageObject_AverageWheelGroundLighting*
# *(DWORD *)&g_weatherViewCount, a one-byte global, low byte used
fun:*StageObject_DeriveLoadedScaleVector*
# *(int *)&g_unk0x0082ca18 & 0xff, a one-byte global
fun:*RallyData_DrawCarSplitTimesPanel*
# *(DWORD *)rgb over BYTE rgb[3], the fog colour's unused alpha
fun:*Track_SetFogAndSkyAlpha*
# *(unsigned int *)&param1 over an unsigned short parameter, used & 0xffff
fun:*ApplyControllerButtonBindings*
# *(unsigned int *)&g_unk0x0052af58[0] & 0xff, the in-race menu's device
# (two bytes the original otherwise reads as bytes)
fun:*InRaceMenu_UpdateStateMachineFrame*
fun:*InRaceMenu_DrawHeaderBar*
# *(unsigned int *)&i, a byte counter passed as a dword; the callee keeps
# its low byte
fun:*InRaceMenu_AdvanceScreenEntries*
# the sample after a curve's last, read at its maximum, where it is weighted
# by zero
fun:*NetRace_InterpolateWordCurve*
# *(unsigned int *)&CGameInfo::m_unk0x005a01bc & 0xff, the session count
fun:*Network_GetEnumeratedSessionCount*

[alignment]
fun:*StageObject_AverageWheelGroundLighting*

# Indexing UBSan reports that is the original's own: a loop's end written as
# &a[n] (or a start as a - 1), or an index into the members after an array,
# which the structures' layout checks keep where the original has them.
[array-bounds]
# end of the loop as &m_sessionPlayers[7].longName
fun:*ResetSessionPlayerTable*
# end as &g_menuStreamPos[6][0]
fun:*FrontendAnimation_ResetMainPath*
# start as pParts - 1, incremented before use
fun:*Mesh_BuildParts*
# end as g_classificationTable + 25
fun:*RallyData_LayoutPlayerSplitBars*
# end as g_sparkTri[3].colour, g_shardTri[3].colour
fun:*CarEffects_Init*
fun:*GlassShard_Draw*
fun:*Debris_Draw*
# end as &g_menuScrollers[12].pMenu
fun:*FrontendScroller_RecomputeAllAttached*
# end as g_saveProfiles + 0x1954, the profiles from their +0x14
fun:*Profile_AssignAvailableCategory*
fun:*Profile_LoadAndLinkSavedRecord*
fun:*SaveProfiles_GetAvailableProfileIndex*
fun:*SaveProfiles_GetAvailableProfileName*
# clears five maps and rect pairs of four, into the members after them
fun:*RallyData_LoadCurrentRallyWeatherTextures*
# items[-1] when the menu lacks the item: the original writes the menu's
# field_0x4, as this layout does
fun:*GameMenu_SetupStageResults*
# end as g_saveCarRecords + 0x62c, within the save data
fun:*FrontendChampionship_InitEntries*
# driver records past the eight, within the save data (SaveBlock)
fun:*RallyData_GetRecord*

# Records the game reads in place from its files, at the file's offsets.
[alignment]
fun:*StageWeather_InitParticleAndLightState*
fun:*StageDeform_ApplyRadialDent*
fun:*StageDeform_ApplyPlanarDent*

# a << aShift with aShift 32 for a texture without alpha, where a is 0
[shift-exponent]
fun:*LoadTGATexture*
