I use Embacadero C++Builder. And I have the following problem:
I used to follow the guidelines and do my best not to have warnings during compilation (by fixing the code, not by disabling warnings).
Also I use std::unique_ptr<>
.
But it turned out that implementation of std::unique_ptr has a bug (at least it triggers warning on 32 bit platform in release mode and when I look at implementation it seems, that the implementation is not hundred percent correct).
The specifics (example code). I try to build the following code with 32 bit compiler in release configuration
#include <memory>
using namespace std;
int main()
{
unique_ptr<int> myUniqueInt;
int * myInt = new int(5);
myUniqueInt = unique_ptr<int>(move(myInt));
return 0;
}
Then I get the warning: [bcc32 Warning] memory(806): W8070 Function should return a value
Now if I look to the source of the warning, I see the following (file "memory", line 798, from standard library):
_Myt& operator=(_Myt&& _Right)
{ // assign by moving _Right
if (this != &_Right)
{ // different, do the move
reset(_Right.release());
this->get_deleter() = _STD move(_Right.get_deleter());
return (*this);
}
}
We can see, that indeed if this == &_Right
, then function does not return any value, so the warning is right.
The questions I have are following:
- Why the warning is not triggered in the Debug configuration - it is only triggered in release?
- How can I overcome this without giving up "treat warnings as errors" globally and without disabling this warning globally.
Notes:
- The warning presents only in Release configuration.
- The warning present on XE6 and XE8 versions of C++Builder
- The warning is not there for 64 bit compiler (which is expected as the compiler is different).
Thanks in advance.