https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82745

--- Comment #6 from helge at penne dot no ---
I'm sorry if I confused you by using the wrong terminology here.  My bad. 
We're now getting to the real issue, and that's great.

You're right that C++ by default allows implicit conversion that loose
precision, but there is an option to enable warnings on this, and the bug I
want to report is that this does not work as it should.  Some important cases
are not detected.

The problem is that "auto foo = std::make_unique<Foo>(1000u);" from the example
does not result in any warning.  However, using unique_ptr and new does.  This
is unexpected and inconsistent.

Similarly, the example from the standards forum shows that similar problems
exist when initialising std::pair.

I'v also found that the compiler does not warn on loss of precision in calls to
"emplace":
vector<char> v;
v.emplace_back(1000); // No warning
v.push_back(1000); // Warning

All this is very bad when you're writing secure code.  I'm sure you're right in
your analysis about why this happens.  The problem is that it really should not
behave in this way.  The compiler needs to consistently warn about loss of
precision if configured to do so.

Reply via email to