On 21 Ago, 16:51, itroot <ivan.tolstoshe...@gmail.com> wrote:
Hello,
how can i make g++ show me warning when such implicit casting occurs?
#include <iostream>
#include <string>
int main() {
int x=10;
std::string s;
s=x; // int implicitly assigned to char, then called
std::string::operator=(char)
}
This piece of code really surprise me, and i'cant found how i can make
g++ warn me.
I want warning on each "narrowing" conversion as char c=(int)(2), etc.
Thanks.
I've stomped on the same issue - and it surprised me just in the same
way.
I think you'll have to live with it, that's a standard, legal
conversion which is explicitly allowed to lose data, I don't think
there is any way to force a compiler warning - somebody else will
eventually correct this statement of mine, shall it be false.
error or warning though.