This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/45385] New: -Wconversion fails to detect a real conversion loss
- From: "mendola at gmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 23 Aug 2010 16:06:17 -0000
- Subject: [Bug c++/45385] New: -Wconversion fails to detect a real conversion loss
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
Hi,
compiling the following code with -Wconversion doesn't give a warning while
with compiler version 4.3.2 does. As you can verify the posted code has a real
conversion loss at runtime giving:
expected: 8000000000
obtained: 3705032704
=================================================================
#include <iostream>
void foo(unsigned int a) { std::cout << "obtained: " << a << std::endl; }
class Test {
public:
void eval() {
foo(bar());
}
private:
unsigned long long bar() const {
unsigned long long ret = 8000000000;
std::cout << "expected: " << ret << std::endl;
return ret;
}
};
int main () {
Test t;
t.eval();
return 1;
}
=================================================================
--
Summary: -Wconversion fails to detect a real conversion loss
Product: gcc
Version: 4.4.3
Status: UNCONFIRMED
Severity: major
Priority: P3
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: mendola at gmail dot com
GCC build triplet: 4.4.3
GCC host triplet: 4.4.3
GCC target triplet: 4.4.3
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45385