Bro*_*nze -1 c++ compilation compiler-warnings
我确信这有一个简单的解释,但我有一些像这样的代码:
RoutingTablePoolEntry rtpe;
RoutingTablePoolEntry* rtpePtr;
if (rtpeItr == m_rtpool.end()) {
RoutingTableEntry* routeEntryPtr = m_nlsr.getRoutingTable()
.findRoutingTableEntry(destRouter);
if (routeEntryPtr == nullptr) {
RoutingTablePoolEntry rtpe(destRouter);
}
else {
RoutingTablePoolEntry rtpe(*routeEntryPtr);
}
RoutingTablePoolEntry* rtpePtr = addRtpeToPool(rtpe);
}
else {
RoutingTablePoolEntry* rtpePtr = &(rtpeItr->second);
}
doSomeStuffWithRtpe()
Run Code Online (Sandbox Code Playgroud)
编辑:这是一些真正的代码.错误是否仍在变量范围内?我在这个例子中意识到,但这仍然是问题吗?我尝试了表单的条件初始化:
RoutingTablePoolEntry rtpe(routeEntryPtr == nullptr? ... : ...);但这似乎也没有合作太多.
编辑#2:我是个白痴,对不起.原因非常清楚,我只是没有看到它.
rtpe = RoutingTablePoolEntry(destRouter)并且
rtpePtr = &(rtpeItr->second)
在很小的机会中,任何人都会这样做.