I believe you are hitting undefined behavior: https://isocpp.org/wiki/faq/ctors#static-init-order
On Monday, August 20, 2018 at 9:10:25 AM UTC-7, Юрий Катков wrote: > > Hi! > I compile my C++ project to wasm using emscripten. > This project is consist of several source files which should be linked in > strict defined order ( due to of inter-dependency of global variables :( ) > > In fact sequence of global initializers is unpredictable for me - I > inspect "/* global initializers */ __ATINIT__.push({..." string in js > file. I tried to reorder input object files in linking step, but it dont > affect on order of global initializers called in js file. > > Unfortunetly I cant share code of my project, but my simple test project > work fine in predictable way. Global initializers calling order is the same > as order of linking of object files. > > What could cause such behaviour? Does order of global initializers is > determine, and can I modify it? > > I attach my simple project, which demonstrates expected behavior. Could > anyone break it? :) > > Thanks a lot! > > -- You received this message because you are subscribed to the Google Groups "emscripten-discuss" group. To unsubscribe from this group and stop receiving emails from it, send an email to emscripten-discuss+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.