B
BSeab1024SE
In MS Visual C++ some code I wrote generated the warning "conversion
from 'int' to 'const float', possible loss of data."
In the process of trying to determine if I could rewrite the code to
eliminate the warning I noticed that the following code did not
generate any warning...
int x = 1024;
char y = x;
The Comeau online compiler generated no warning either.
I thought this would generate a warning also given the narrower width
of the char and the fact that the value of x will not be preserved in
y.
It is not terribly relevant to what I am doing but I am looking to
gain insight.
Any thoughts on why the above code generated no warning (I really hope
I am not missing something obvious.)
Also, does the C++ standard dictate the types of statements that
should generate warnings or is that left to the compiler author?
Regards,
Brian
from 'int' to 'const float', possible loss of data."
In the process of trying to determine if I could rewrite the code to
eliminate the warning I noticed that the following code did not
generate any warning...
int x = 1024;
char y = x;
The Comeau online compiler generated no warning either.
I thought this would generate a warning also given the narrower width
of the char and the fact that the value of x will not be preserved in
y.
It is not terribly relevant to what I am doing but I am looking to
gain insight.
Any thoughts on why the above code generated no warning (I really hope
I am not missing something obvious.)
Also, does the C++ standard dictate the types of statements that
should generate warnings or is that left to the compiler author?
Regards,
Brian