[gnudatalanguage-devel] C++ return types
Status: Beta
Brought to you by:
m_schellens
|
From: Orion P. <or...@nw...> - 2018-04-11 21:33:29
|
One thing that as come up with GCC 8 are C++ warnings like this:
warning: no return statement in function returning non-void [-Wreturn-type]
Which can lead to crashes as this is undefined behavior in C++. So I've
started taking a look at those warnings in GDL. One that I can't figure out is:
/builddir/build/BUILD/gdl-0.9.8/src/saverestore.cpp:167:3: warning: no return
statement in function returning non-void [-Wreturn-type]
This is here:
uint32_t writeEnd(XDR *xdrs) {
uint32_t cur=writeNewRecordHeader(xdrs, 6);
}
I think we're missing "return cur"?
It's called here:
nextptr=writeEnd(xdrs);
but then nextptr is never accessed.
There are also a lot of warning like:
/builddir/build/BUILD/gdl-0.9.8/src/basic_pro_jmg.cpp:297:13: warning: control
reaches end of non-void function [-Wreturn-type]
for functions that must return earlier and end with something like:
assert( false);
}
I'm thinking of adding:
return 0 // Not reached
to at least quiet the warning. Thoughts?
--
Orion Poplawski
Manager of NWRA Technical Systems 720-772-5637
NWRA, Boulder/CoRA Office FAX: 303-415-9702
3380 Mitchell Lane or...@nw...
Boulder, CO 80301 https://www.nwra.com/
|