0

In a compute shader model 5, I have the result of some computation in a double precision floting point value. I have to assign the value to an integer variable and I get the warning:

warning X3205: 'round': conversion from larger type to smaller, possible loss of data

I understand the warning but in my case, at runtime the floating point value will never exceed the value acceptable for an integer. The code produce the expected result so I want to shut off that warning for the specific offending line.

I don't find how to turn off specific warning and I like to write code that do not produce any warning or if they are, they are checked to see if they are false alarm or not.

Any help appreciated.

fpiette
  • 11,983
  • 1
  • 24
  • 46

1 Answers1

1

You did not supply your code, and I suppose it was something in the form of:

double doubleValue = 1.0;
int integer = round(doubleValue);

If you want to suppress the warning, and you are sure the data you are dealing with will not give funny results, you can cast the double to a float before passing it to round().

double doubleValue = 1.0;
int integer = round((float)doubleValue);

This form does not trigger the warning.

kefren
  • 1,042
  • 7
  • 12
  • Will try that. While waiting for an answer, I wrote a preprocessor for the source code and a post processor for the error blob. The preprocessor allow some directives (Seen as comments by the compiler) and then postprocess the error blob to eliminate the warnings which are acceptable and keep the others. – fpiette Sep 23 '19 at 19:45
  • Eliminating the errors indeed gives you the result you aimed for, but it would also eliminate subsequent occurrences of the warning that might be relevant for you. – kefren Sep 23 '19 at 20:11
  • No, the directive I created only suppress the warning on the line below the directive. It looks like "//$WARN_IGNORE_ONCE 'warning X3205: ''round'''". On the preprocess pass, it record the next line number containing code after the directive and the postprocess remove from the error blob the line with that line number and having the string given in the directive. No danger to suppress anything not wanted. – fpiette Sep 24 '19 at 05:34