[Scummvm-tracker] [ScummVM :: Bugs] #17412: Build fails with strict-aliasing violations

ScummVM :: Bugs trac at scummvm.org
Mon Oct 19 17:59:57 UTC 2026


#17412: Build fails with strict-aliasing violations
-------------------------+-----------------------
Reporter:  eli-schwartz  |      Owner:  (none)
    Type:  defect        |     Status:  new
Priority:  normal        |  Component:  --Unset--
 Version:                |   Keywords:
    Game:                |
-------------------------+-----------------------
 I tried to build with the following *FLAGS to optimize the build: `-flto=4
 -Werror=odr -Werror=lto-type-mismatch -Werror=strict-aliasing`

 The -Werror=* flags are important to detect cases where the compiler can
 try to optimize based on assuming Undefined Behavior (UB) cannot happen,
 and miscompile code that has UB in it. strict-aliasing issues are always
 bad but LTO can make them even worse.

 I got this error:
 ```
 x86_64-pc-linux-gnu-g++  [....] -Wall -pipe -march=native -fstack-
 protector-all -O3 -fdiagnostics-color=always -frecord-gcc-switches
 -freport-bug -flto=4 -Werror=odr -Werror=lto-type-mismatch -Werror=strict-
 aliasing  -Wformat -Werror=format-security  -Wshadow -Wno-stringop-
 overflow -Wno-stringop-truncation -W -Wno-unused-parameter -Wno-empty-body
 -fno-operator-names  [...]  -c
 engines/hpl1/engine/libraries/angelscript/sources/as_bytecode.cpp -o
 engines/hpl1/engine/libraries/angelscript/sources/as_bytecode.o
 In file included from
 engines/hpl1/engine/libraries/angelscript/sources/as_bytecode.cpp:40:
 engines/hpl1/engine/libraries/angelscript/sources/as_bytecode.cpp: In
 member function ‘bool asCByteCode::RemoveUnusedValue(asCByteInstruction*,
 asCByteInstruction**)’:
 engines/hpl1/engine/libraries/angelscript/sources/as_config.h:1350:23:
 error: dereferencing type-punned pointer will break strict-aliasing rules
 [-Werror=strict-aliasing]
  1350 | #define ARG_DW(b)    ((asDWORD*)&b)
       |                      ~^~~~~~~~~~~~~
 engines/hpl1/engine/libraries/angelscript/sources/as_bytecode.cpp:473:69:
 note: in expansion of macro ‘ARG_DW’
   473 |                         *(((asDWORD *)&curr->arg) + AS_PTR_SIZE) =
 *ARG_DW(curr->arg);
       |
 ^~~~~~
 engines/hpl1/engine/libraries/angelscript/sources/as_bytecode.cpp: In
 member function ‘void asCByteCode::OptimizeLocally(const asCArray<int>&)’:
 engines/hpl1/engine/libraries/angelscript/sources/as_bytecode.cpp:822:34:
 error: dereferencing type-punned pointer will break strict-aliasing rules
 [-Werror=strict-aliasing]
   822 |                                 *(asDWORD *)&instr->arg =
 *(asDWORD *)&instr->next->arg;
       |                                  ^~~~~~~~~~~~~~~~~~~~~~
 engines/hpl1/engine/libraries/angelscript/sources/as_bytecode.cpp:822:60:
 error: dereferencing type-punned pointer will break strict-aliasing rules
 [-Werror=strict-aliasing]
   822 |                                 *(asDWORD *)&instr->arg =
 *(asDWORD *)&instr->next->arg;
       |
 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
 engines/hpl1/engine/libraries/angelscript/sources/as_bytecode.cpp:835:34:
 error: dereferencing type-punned pointer will break strict-aliasing rules
 [-Werror=strict-aliasing]

 [...]

 engines/hpl1/engine/libraries/angelscript/sources/as_bytecode.cpp: In
 member function ‘asDWORD asCByteCode::GetLastInstrValueDW()’:
 engines/hpl1/engine/libraries/angelscript/sources/as_config.h:1350:23:
 error: dereferencing type-punned pointer will break strict-aliasing rules
 [-Werror=strict-aliasing]
  1350 | #define ARG_DW(b)    ((asDWORD*)&b)
       |                      ~^~~~~~~~~~~~~
 engines/hpl1/engine/libraries/angelscript/sources/as_bytecode.cpp:2655:17:
 note: in expansion of macro ‘ARG_DW’
  2655 |         return *ARG_DW(last->arg);
       |                 ^~~~~~
 cc1plus: some warnings being treated as errors
 make: *** [Makefile.common:176:
 engines/hpl1/engine/libraries/angelscript/sources/as_bytecode.o] Error 1
 mkdir -p engines/hpl1/engine/libraries/angelscript/sources/.deps

 [...]

 mkdir -p engines/dragons/.deps
 x86_64-pc-linux-gnu-g++ [...] -Wall -pipe -march=native -fstack-protector-
 all -O3 -fdiagnostics-color=always -frecord-gcc-switches -freport-bug
 -flto=4 -Werror=odr -Werror=lto-type-mismatch -Werror=strict-aliasing
 -Wformat -Werror=format-security  -Wshadow -Wno-stringop-overflow -Wno-
 stringop-truncation -W -Wno-unused-parameter -Wno-empty-body -fno-
 operator-names [...]  -c engines/dragons/minigame3.cpp -o
 engines/dragons/minigame3.o
 engines/dragons/minigame3.cpp: In member function ‘void
 Dragons::Minigame3::run()’:
 engines/dragons/minigame3.cpp:360:72: error: dereferencing type-punned
 pointer will break strict-aliasing rules [-Werror=strict-aliasing]
   360 |                                                 local_56 =
 local_56 - *(int16 *)&UnkStruct_ARRAY_800931a0[local_50].field_0x14;
       |
 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 cc1plus: some warnings being treated as errors
 make: *** [Makefile.common:177: engines/dragons/minigame3.o] Error 1
 make: *** [Makefile.common:177:
 engines/hpl1/engine/libraries/angelscript/sources/as_context.o] Error 1
 make: *** [Makefile.common:177: engines/twp/squirrel/sqcompiler.o] Error 1
 make: *** [Makefile.common:177: engines/director/lingo/lingodec/handler.o]
 Error 1
 make: *** [Makefile.common:177: engines/director/debugger/dt-script-d4.o]
 Error 1
 make: *** [Makefile.common:177: engines/ags/plugins/ags_plugin.o] Error 1
 make: *** [Makefile.common:177: engines/pelrock/saveload.o] Error 1
 make: *** [Makefile.common:177:
 engines/wintermute/base/gfx/xfile_loader.o] Error 1
 make: *** [Makefile.common:177:
 engines/hpl1/engine/libraries/angelscript/sources/as_restore.o] Error 1
 make: *** [Makefile.common:177: engines/twp/squirrel/sqvm.o] Error 1
 make: *** [Makefile.common:177: engines/director/lingo/lingo.o] Error 1
 make: Target 'all' not remade because of errors.

 ```

 Originally reported downstream: https://bugs.gentoo.org/968927
 Full error output is very, very very long, trimmed for size. Build log
 attached.

 Errors show up across various engines, so not sure what component to set
 this as
-- 
Ticket URL: <https://bugs.scummvm.org/ticket/17412>
ScummVM :: Bugs <https://bugs.scummvm.org>
ScummVM


More information about the Scummvm-tracker mailing list