[Bug c++/45385] New: -Wconversion fails to detect a real conversion loss
mendola at gmail dot com
gcc-bugzilla@gcc.gnu.org
Mon Aug 23 16:06:00 GMT 2010
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
More information about the Gcc-bugs
mailing list