- Environment: Windows10, cpp17, visual studio 2019, debug version static library
Recently I tried to use Cesium-Native to read 3DTiles files in my project, but there was a confusing problem that some member variables are not initialized correctly.
As following codes show, Tileset() use initializer list to initialize its member variables, but some of them like_loadsInProgress,_previousFrameNumber are initialized to random value which shoule have been 0. However some of them are initialize correctly like _url, _options, and it works well in Release Library and the same code in its original project. What a strange bug!
Tileset::Tileset(
const TilesetExternals& externals,
const std::string& url,
const TilesetOptions& options)
: _externals(externals),
_asyncSystem(externals.asyncSystem),
_userCredit(
(options.credit && externals.pCreditSystem)
? std::optional<Credit>(externals.pCreditSystem->createCredit(
options.credit.value(),
options.showCreditsOnScreen))
: std::nullopt),
_url(url),
_isRefreshingIonToken(false),
_options(options),
_pRootTile(),
_previousFrameNumber(0),
_loadsInProgress(0),
_subtreeLoadsInProgress(0),
_overlays(*this),
_tileDataBytes(0),
_supportsRasterOverlays(false),
_gltfUpAxis(CesiumGeometry::Axis::Y),
_distancesStack(),
_nextDistancesVector(0) {
if (!url.empty()) {
CESIUM_TRACE_USE_TRACK_SET(this->_loadingSlots);
this->notifyTileStartLoading(nullptr);
LoadTilesetDotJson::start(*this, url).thenInMainThread([this]() {
this->notifyTileDoneLoading(nullptr);
});
}
}
Through debugging, I found that _loadsInProgress was 0 at first, and it changes when a vector construct function is called. Maybe it's because generation of debug static lib?
Any suggestions will be appreciated!
0xe4ff3a10, which seems like a block of memory just allocated. And this is their libray code, my code actually are very short. But I really don't understand why constructor don't initialize member variables correctly